1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import {CallerTransformOptions} from '@jest/transform';
|
8 | import type {Config} from '@jest/types';
|
9 | import type {expect} from '@jest/globals';
|
10 | import type {Global} from '@jest/types';
|
11 | import {IHasteMap} from 'jest-haste-map';
|
12 | import {IModuleMap} from 'jest-haste-map';
|
13 | import type {JestEnvironment} from '@jest/environment';
|
14 | import Resolver from 'jest-resolve';
|
15 | import {ScriptTransformer} from '@jest/transform';
|
16 | import {shouldInstrument} from '@jest/transform';
|
17 | import {ShouldInstrumentOptions} from '@jest/transform';
|
18 | import type {SourceMapRegistry} from '@jest/source-map';
|
19 | import type {TestContext} from '@jest/test-result';
|
20 | import type {V8CoverageResult} from '@jest/test-result';
|
21 |
|
22 | declare type HasteMapOptions = {
|
23 | console?: Console;
|
24 | maxWorkers: number;
|
25 | resetCache: boolean;
|
26 | watch?: boolean;
|
27 | watchman: boolean;
|
28 | workerThreads?: boolean;
|
29 | };
|
30 |
|
31 | declare interface InternalModuleOptions
|
32 | extends Required<CallerTransformOptions> {
|
33 | isInternalModule: boolean;
|
34 | }
|
35 |
|
36 | declare interface JestGlobals extends Global.TestFrameworkGlobals {
|
37 | expect: typeof expect;
|
38 | }
|
39 |
|
40 | declare class Runtime {
|
41 | private readonly _cacheFS;
|
42 | private readonly _cacheFSBuffer;
|
43 | private readonly _config;
|
44 | private readonly _globalConfig?;
|
45 | private readonly _coverageOptions;
|
46 | private _currentlyExecutingModulePath;
|
47 | private readonly _environment;
|
48 | private readonly _explicitShouldMock;
|
49 | private readonly _explicitShouldMockModule;
|
50 | private _fakeTimersImplementation;
|
51 | private readonly _internalModuleRegistry;
|
52 | private _isCurrentlyExecutingManualMock;
|
53 | private _mainModule;
|
54 | private readonly _mockFactories;
|
55 | private readonly _mockMetaDataCache;
|
56 | private _mockRegistry;
|
57 | private _isolatedMockRegistry;
|
58 | private readonly _moduleMockRegistry;
|
59 | private readonly _moduleMockFactories;
|
60 | private readonly _moduleMocker;
|
61 | private _isolatedModuleRegistry;
|
62 | private _moduleRegistry;
|
63 | private readonly _esmoduleRegistry;
|
64 | private readonly _cjsNamedExports;
|
65 | private readonly _esmModuleLinkingMap;
|
66 | private readonly _testPath;
|
67 | private readonly _resolver;
|
68 | private _shouldAutoMock;
|
69 | private readonly _shouldMockModuleCache;
|
70 | private readonly _shouldUnmockTransitiveDependenciesCache;
|
71 | private readonly _sourceMapRegistry;
|
72 | private readonly _scriptTransformer;
|
73 | private readonly _fileTransforms;
|
74 | private readonly _fileTransformsMutex;
|
75 | private _v8CoverageInstrumenter;
|
76 | private _v8CoverageResult;
|
77 | private _v8CoverageSources;
|
78 | private readonly _transitiveShouldMock;
|
79 | private _unmockList;
|
80 | private readonly _virtualMocks;
|
81 | private readonly _virtualModuleMocks;
|
82 | private _moduleImplementation?;
|
83 | private readonly jestObjectCaches;
|
84 | private jestGlobals?;
|
85 | private readonly esmConditions;
|
86 | private readonly cjsConditions;
|
87 | private isTornDown;
|
88 | constructor(
|
89 | config: Config.ProjectConfig,
|
90 | environment: JestEnvironment,
|
91 | resolver: Resolver,
|
92 | transformer: ScriptTransformer,
|
93 | cacheFS: Map<string, string>,
|
94 | coverageOptions: ShouldInstrumentOptions,
|
95 | testPath: string,
|
96 | globalConfig?: Config.GlobalConfig,
|
97 | );
|
98 | static shouldInstrument: typeof shouldInstrument;
|
99 | static createContext(
|
100 | config: Config.ProjectConfig,
|
101 | options: {
|
102 | console?: Console;
|
103 | maxWorkers: number;
|
104 | watch?: boolean;
|
105 | watchman: boolean;
|
106 | },
|
107 | ): Promise<TestContext>;
|
108 | static createHasteMap(
|
109 | config: Config.ProjectConfig,
|
110 | options?: HasteMapOptions,
|
111 | ): Promise<IHasteMap>;
|
112 | static createResolver(
|
113 | config: Config.ProjectConfig,
|
114 | moduleMap: IModuleMap,
|
115 | ): Resolver;
|
116 | static runCLI(): Promise<never>;
|
117 | static getCLIOptions(): never;
|
118 | unstable_shouldLoadAsEsm(modulePath: string): boolean;
|
119 | private loadEsmModule;
|
120 | private resolveModule;
|
121 | private linkAndEvaluateModule;
|
122 | unstable_importModule(
|
123 | from: string,
|
124 | moduleName?: string,
|
125 | ): Promise<unknown | void>;
|
126 | private loadCjsAsEsm;
|
127 | private importMock;
|
128 | private getExportsOfCjs;
|
129 | requireModule<T = unknown>(
|
130 | from: string,
|
131 | moduleName?: string,
|
132 | options?: InternalModuleOptions,
|
133 | isRequireActual?: boolean,
|
134 | ): T;
|
135 | requireInternalModule<T = unknown>(from: string, to?: string): T;
|
136 | requireActual<T = unknown>(from: string, moduleName: string): T;
|
137 | requireMock<T = unknown>(from: string, moduleName: string): T;
|
138 | private _loadModule;
|
139 | private _getFullTransformationOptions;
|
140 | requireModuleOrMock<T = unknown>(from: string, moduleName: string): T;
|
141 | isolateModules(fn: () => void): void;
|
142 | isolateModulesAsync(fn: () => Promise<void>): Promise<void>;
|
143 | resetModules(): void;
|
144 | collectV8Coverage(): Promise<void>;
|
145 | stopCollectingV8Coverage(): Promise<void>;
|
146 | getAllCoverageInfoCopy(): JestEnvironment['global']['__coverage__'];
|
147 | getAllV8CoverageInfoCopy(): V8CoverageResult;
|
148 | getSourceMaps(): SourceMapRegistry;
|
149 | setMock(
|
150 | from: string,
|
151 | moduleName: string,
|
152 | mockFactory: () => unknown,
|
153 | options?: {
|
154 | virtual?: boolean;
|
155 | },
|
156 | ): void;
|
157 | private setModuleMock;
|
158 | restoreAllMocks(): void;
|
159 | resetAllMocks(): void;
|
160 | clearAllMocks(): void;
|
161 | teardown(): void;
|
162 | private _resolveCjsModule;
|
163 | private _resolveModule;
|
164 | private _requireResolve;
|
165 | private _requireResolvePaths;
|
166 | private _execModule;
|
167 | private transformFile;
|
168 | private transformFileAsync;
|
169 | private createScriptFromCode;
|
170 | private _requireCoreModule;
|
171 | private _importCoreModule;
|
172 | private _importWasmModule;
|
173 | private _getMockedNativeModule;
|
174 | private _generateMock;
|
175 | private _shouldMockCjs;
|
176 | private _shouldMockModule;
|
177 | private _createRequireImplementation;
|
178 | private _createJestObjectFor;
|
179 | private _logFormattedReferenceError;
|
180 | private wrapCodeInModuleWrapper;
|
181 | private constructModuleWrapperStart;
|
182 | private constructInjectedModuleParameters;
|
183 | private handleExecutionError;
|
184 | private getGlobalsForCjs;
|
185 | private getGlobalsForEsm;
|
186 | private getGlobalsFromEnvironment;
|
187 | private readFileBuffer;
|
188 | private readFile;
|
189 | setGlobalsForRuntime(globals: JestGlobals): void;
|
190 | }
|
191 | export default Runtime;
|
192 |
|
193 | export {};
|