UNPKG

3.21 kBTypeScriptView Raw
1import type { BuildCtx, Cache, CompilerCtx, Config, LoadConfigInit, ValidatedConfig, Module, UnvalidatedConfig } from '@stencil/core/internal';
2import { TestingSystem } from './testing-sys';
3import { TestingLogger } from './testing-logger';
4/**
5 * Creates a mock instance of an internal, validated Stencil configuration object
6 * the caller
7 * @param overrides a partial implementation of `ValidatedConfig`. Any provided fields will override the defaults
8 * provided by this function.
9 * @returns the mock Stencil configuration
10 */
11export declare function mockValidatedConfig(overrides?: Partial<ValidatedConfig>): ValidatedConfig;
12/**
13 * Creates a mock instance of a Stencil configuration entity. The mocked configuration has no guarantees around the
14 * types/validity of its data.
15 * @param overrides a partial implementation of `UnvalidatedConfig`. Any provided fields will override the defaults
16 * provided by this function.
17 * @returns the mock Stencil configuration
18 */
19export declare function mockConfig(overrides?: Partial<UnvalidatedConfig>): UnvalidatedConfig;
20/**
21 * Creates a configuration object used to bootstrap a Stencil task invocation
22 *
23 * Several fields are intentionally undefined for this entity. While it would be trivial to stub them out, this mock
24 * generation function operates under the assumption that entities like loggers and compiler system abstractions will
25 * be shared by multiple entities in a test suite, who should provide those entities to this function
26 *
27 * @param overrides the properties on the default entity to manually override
28 * @returns the default configuration initialization object, with any overrides applied
29 */
30export declare const mockLoadConfigInit: (overrides?: Partial<LoadConfigInit>) => LoadConfigInit;
31export declare function mockCompilerCtx(config?: Config): CompilerCtx;
32export declare function mockBuildCtx(config?: Config, compilerCtx?: CompilerCtx): BuildCtx;
33export declare function mockCache(config?: Config, compilerCtx?: CompilerCtx): Cache;
34export declare function mockLogger(): TestingLogger;
35/**
36 * Create a {@link CompilerSystem} entity for testing the compiler.
37 *
38 * This function acts as a thin wrapper around a {@link TestingSystem} entity creation. It exists to provide a logical
39 * place in the codebase where we might expect Stencil engineers to reach for when attempting to mock a
40 * {@link CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
41 * reconsider if this wrapper is necessary.
42 *
43 * @returns a System instance for testing purposes.
44 */
45export declare function mockCompilerSystem(): TestingSystem;
46export declare function mockDocument(html?: string): Document;
47export declare function mockWindow(html?: string): Window;
48/**
49 * This gives you a mock Module, an interface which is the internal compiler
50 * representation of a module. It includes a bunch of information necessary for
51 * compilation, this mock basically sets sane defaults for all those values.
52 *
53 * @param mod is an override module that you can supply to set particular values
54 * @returns a module object ready to use in tests!
55 */
56export declare const mockModule: (mod?: Partial<Module>) => Module;