@stencil/core 2.16.1-0 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/config-flags.d.ts +102 -0
- package/cli/index.cjs +697 -224
- package/cli/index.d.ts +2 -1
- package/cli/index.js +697 -224
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +856 -290
- package/compiler/stencil.min.js +2 -2
- package/dependencies.json +1 -1
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +11 -6
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/index.js +2 -2
- package/internal/hydrate/package.json +1 -1
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +6 -2
- package/internal/stencil-public-compiler.d.ts +67 -48
- package/internal/testing/index.js +1 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +140 -5
- package/mock-doc/index.d.ts +76 -1
- package/mock-doc/index.js +140 -5
- package/mock-doc/package.json +1 -1
- package/package.json +2 -1
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +325 -314
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.d.ts +1 -1
- package/testing/index.js +436 -381
- package/testing/jest/jest-config.d.ts +1 -1
- package/testing/jest/jest-runner.d.ts +3 -2
- package/testing/jest/jest-screenshot.d.ts +1 -1
- package/testing/mocks.d.ts +48 -3
- package/testing/package.json +1 -1
- package/testing/puppeteer/puppeteer-browser.d.ts +2 -2
- package/testing/test/testing-utils.spec.d.ts +1 -0
- package/testing/testing-utils.d.ts +74 -2
- package/testing/testing.d.ts +2 -2
|
@@ -5,7 +5,7 @@ import type { Config } from '@jest/types';
|
|
|
5
5
|
* @param config the Stencil config to use while generating Jest CLI arguments
|
|
6
6
|
* @returns the arguments to pass to the Jest CLI, wrapped in an object
|
|
7
7
|
*/
|
|
8
|
-
export declare function buildJestArgv(config: d.
|
|
8
|
+
export declare function buildJestArgv(config: d.ValidatedConfig): Config.Argv;
|
|
9
9
|
/**
|
|
10
10
|
* Generate a Jest run configuration to be used as a part of the `argv` passed to the Jest CLI when it is invoked
|
|
11
11
|
* programmatically
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type * as d from '@stencil/core/internal';
|
|
2
|
-
|
|
2
|
+
import type { ConfigFlags } from '../../cli/config-flags';
|
|
3
|
+
export declare function runJest(config: d.ValidatedConfig, env: d.E2EProcessEnv): Promise<boolean>;
|
|
3
4
|
/**
|
|
4
5
|
* Creates a Stencil test runner
|
|
5
6
|
* @returns the test runner
|
|
6
7
|
*/
|
|
7
8
|
export declare function createTestRunner(): any;
|
|
8
9
|
export declare function includeTestFile(testPath: string, env: d.E2EProcessEnv): boolean;
|
|
9
|
-
export declare function getEmulateConfigs(testing: d.TestingConfig, flags:
|
|
10
|
+
export declare function getEmulateConfigs(testing: d.TestingConfig, flags: ConfigFlags): d.EmulateConfig[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type * as d from '@stencil/core/internal';
|
|
2
|
-
export declare function runJestScreenshot(config: d.
|
|
2
|
+
export declare function runJestScreenshot(config: d.ValidatedConfig, env: d.E2EProcessEnv): Promise<boolean>;
|
package/testing/mocks.d.ts
CHANGED
|
@@ -1,10 +1,55 @@
|
|
|
1
|
-
import type { BuildCtx, Cache, CompilerCtx, CompilerSystem, Config } from '@stencil/core/internal';
|
|
1
|
+
import type { BuildCtx, Cache, CompilerCtx, CompilerSystem, Config, LoadConfigInit, ValidatedConfig, Module, UnvalidatedConfig } from '@stencil/core/internal';
|
|
2
|
+
import { TestingSystem } from './testing-sys';
|
|
2
3
|
import { TestingLogger } from './testing-logger';
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Creates a mock instance of an internal, validated Stencil configuration object
|
|
6
|
+
* @param sys an optional compiler system to associate with the config. If one is not provided, one will be created for
|
|
7
|
+
* the caller
|
|
8
|
+
* @returns the mock Stencil configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function mockValidatedConfig(sys?: CompilerSystem): ValidatedConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a mock instance of a Stencil configuration entity. The mocked configuration has no guarantees around the
|
|
13
|
+
* types/validity of its data.
|
|
14
|
+
* @param sys an optional compiler system to associate with the config. If one is not provided, one will be created for
|
|
15
|
+
* the caller
|
|
16
|
+
* @returns the mock Stencil configuration
|
|
17
|
+
*/
|
|
18
|
+
export declare function mockConfig(sys?: CompilerSystem): UnvalidatedConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a configuration object used to bootstrap a Stencil task invocation
|
|
21
|
+
*
|
|
22
|
+
* Several fields are intentionally undefined for this entity. While it would be trivial to stub them out, this mock
|
|
23
|
+
* generation function operates under the assumption that entities like loggers and compiler system abstractions will
|
|
24
|
+
* be shared by multiple entities in a test suite, who should provide those entities to this function
|
|
25
|
+
*
|
|
26
|
+
* @param overrides the properties on the default entity to manually override
|
|
27
|
+
* @returns the default configuration initialization object, with any overrides applied
|
|
28
|
+
*/
|
|
29
|
+
export declare const mockLoadConfigInit: (overrides?: Partial<LoadConfigInit>) => LoadConfigInit;
|
|
4
30
|
export declare function mockCompilerCtx(config?: Config): CompilerCtx;
|
|
5
31
|
export declare function mockBuildCtx(config?: Config, compilerCtx?: CompilerCtx): BuildCtx;
|
|
6
32
|
export declare function mockCache(config?: Config, compilerCtx?: CompilerCtx): Cache;
|
|
7
33
|
export declare function mockLogger(): TestingLogger;
|
|
8
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Create a {@link CompilerSystem} entity for testing the compiler.
|
|
36
|
+
*
|
|
37
|
+
* This function acts as a thin wrapper around a {@link TestingSystem} entity creation. It exists to provide a logical
|
|
38
|
+
* place in the codebase where we might expect Stencil engineers to reach for when attempting to mock a
|
|
39
|
+
* {@link CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
|
|
40
|
+
* reconsider if this wrapper is necessary.
|
|
41
|
+
*
|
|
42
|
+
* @returns a System instance for testing purposes.
|
|
43
|
+
*/
|
|
44
|
+
export declare function mockCompilerSystem(): TestingSystem;
|
|
9
45
|
export declare function mockDocument(html?: string): Document;
|
|
10
46
|
export declare function mockWindow(html?: string): Window;
|
|
47
|
+
/**
|
|
48
|
+
* This gives you a mock Module, an interface which is the internal compiler
|
|
49
|
+
* representation of a module. It includes a bunch of information necessary for
|
|
50
|
+
* compilation, this mock basically sets sane defaults for all those values.
|
|
51
|
+
*
|
|
52
|
+
* @param mod is an override module that you can supply to set particular values
|
|
53
|
+
* @returns a module object ready to use in tests!
|
|
54
|
+
*/
|
|
55
|
+
export declare const mockModule: (mod?: Partial<Module>) => Module;
|
package/testing/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ValidatedConfig } from '@stencil/core/internal';
|
|
2
2
|
import type * as puppeteer from 'puppeteer';
|
|
3
|
-
export declare function startPuppeteerBrowser(config:
|
|
3
|
+
export declare function startPuppeteerBrowser(config: ValidatedConfig): Promise<puppeteer.Browser>;
|
|
4
4
|
export declare function connectBrowser(): Promise<any>;
|
|
5
5
|
export declare function disconnectBrowser(browser: puppeteer.Browser): Promise<void>;
|
|
6
6
|
export declare function newBrowserPage(browser: puppeteer.Browser): Promise<puppeteer.Page>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,78 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
1
2
|
import type * as d from '@stencil/core/internal';
|
|
2
3
|
export declare function shuffleArray(array: any[]): any[];
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Testing utility to validate the existence of some provided file paths using a specific file system
|
|
6
|
+
*
|
|
7
|
+
* @param fs the file system to use to validate the existence of some files
|
|
8
|
+
* @param filePaths the paths to validate
|
|
9
|
+
* @throws when one or more of the provided file paths cannot be found
|
|
10
|
+
*/
|
|
11
|
+
export declare function expectFilesExist(fs: d.InMemoryFileSystem, filePaths: string[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Testing utility to validate the non-existence of some provided file paths using a specific file system
|
|
14
|
+
*
|
|
15
|
+
* @param fs the file system to use to validate the non-existence of some files
|
|
16
|
+
* @param filePaths the paths to validate
|
|
17
|
+
* @throws when one or more of the provided file paths is found
|
|
18
|
+
*/
|
|
19
|
+
export declare function expectFilesDoNotExist(fs: d.InMemoryFileSystem, filePaths: string[]): void;
|
|
5
20
|
export declare function getAppScriptUrl(config: d.Config, browserUrl: string): string;
|
|
6
21
|
export declare function getAppStyleUrl(config: d.Config, browserUrl: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Utility for silencing `console` functions in tests.
|
|
24
|
+
*
|
|
25
|
+
* When this function is first called it grabs a reference to the `log`,
|
|
26
|
+
* `error`, and `warn` functions on `console` and then returns a per-test setup
|
|
27
|
+
* function which sets up a fresh set of mocks (via `jest.fn()`) and then
|
|
28
|
+
* assigns them to each of these functions. This setup function will return a
|
|
29
|
+
* reference to each of the three mock functions so tests can make assertions
|
|
30
|
+
* about their calls and so on.
|
|
31
|
+
*
|
|
32
|
+
* Because references to the original `.log`, `.error`, and `.warn` functions
|
|
33
|
+
* exist in closure within the function, it can use an `afterAll` call to clean
|
|
34
|
+
* up after itself and ensure that the original implementations are restored
|
|
35
|
+
* after the test suite finishes.
|
|
36
|
+
*
|
|
37
|
+
* An example of using this to silence log statements in a single test could look
|
|
38
|
+
* like this:
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* describe("my-test-suite", () => {
|
|
42
|
+
* const setupConsoleMocks = setupConsoleMocker()
|
|
43
|
+
*
|
|
44
|
+
* it("should log a message", () => {
|
|
45
|
+
* const { logMock } = setupConsoleMocks();
|
|
46
|
+
* myFunctionWhichLogs(foo, bar);
|
|
47
|
+
* expect(logMock).toBeCalledWith('my log message');
|
|
48
|
+
* })
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @returns a per-test mock setup function
|
|
53
|
+
*/
|
|
54
|
+
export declare function setupConsoleMocker(): ConsoleMocker;
|
|
55
|
+
interface ConsoleMocker {
|
|
56
|
+
(): {
|
|
57
|
+
logMock: jest.Mock<typeof console.log>;
|
|
58
|
+
warnMock: jest.Mock<typeof console.warn>;
|
|
59
|
+
errorMock: jest.Mock<typeof console.error>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* the callback that `withSilentWarn` expects to receive. Basically receives a mock
|
|
64
|
+
* as its argument and returns a `Promise`, the value of which is returns by `withSilentWarn`
|
|
65
|
+
* as well.
|
|
66
|
+
*/
|
|
67
|
+
declare type SilentWarnFunc<T> = (mock: jest.Mock<typeof console.warn>) => Promise<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Wrap a single callback with a silent `console.warn`. The callback passed in
|
|
70
|
+
* receives the mocking function as an argument, so you can easily make assertions
|
|
71
|
+
* that it is called if necessary.
|
|
72
|
+
*
|
|
73
|
+
* @param cb a callback which `withSilentWarn` will call after replacing `console.warn`
|
|
74
|
+
* with a mock.
|
|
75
|
+
* @returns a Promise wrapping the return value of the callback
|
|
76
|
+
*/
|
|
77
|
+
export declare function withSilentWarn<T>(cb: SilentWarnFunc<T>): Promise<T>;
|
|
78
|
+
export {};
|
package/testing/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createTesting: (config:
|
|
1
|
+
import type { ValidatedConfig, Testing } from '@stencil/core/internal';
|
|
2
|
+
export declare const createTesting: (config: ValidatedConfig) => Promise<Testing>;
|