vitest 4.0.0-beta.9 → 4.0.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/LICENSE.md +86 -102
- package/browser/context.d.ts +7 -0
- package/browser/context.js +20 -0
- package/dist/browser.d.ts +24 -7
- package/dist/browser.js +15 -5
- package/dist/chunks/{base.CA5N8Af0.js → base.BYPMk0VN.js} +36 -36
- package/dist/chunks/{benchmark.CJUa-Hsa.js → benchmark.DHKMYAts.js} +2 -2
- package/dist/chunks/{browser.d.DtfyY9yS.d.ts → browser.d.B9iJzZyn.d.ts} +3 -3
- package/dist/chunks/{cac.Dt7e1TIu.js → cac.DrF4Gm0S.js} +47 -73
- package/dist/chunks/{cli-api.eAzsLIxz.js → cli-api.W2Q-JQoO.js} +1524 -296
- package/dist/chunks/{config.d.DacWrqWe.d.ts → config.d.u2CUDWwS.d.ts} +5 -19
- package/dist/chunks/{console.7h5kHUIf.js → console.CTJL2nuH.js} +4 -6
- package/dist/chunks/{coverage.CDRAMTt7.js → coverage.FU3w4IrQ.js} +125 -1108
- package/dist/chunks/{creator.KEg6n5IC.js → creator.DucAaYBz.js} +10 -37
- package/dist/chunks/{defaults.CXFFjsi8.js → defaults.BOqNVLsY.js} +0 -1
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/{global.d.K6uBQHzY.d.ts → global.d.BgJSTpgQ.d.ts} +2 -17
- package/dist/chunks/{globals.CJrTTbxC.js → globals.BGT_RUsD.js} +11 -7
- package/dist/chunks/{index.BjKEiSn0.js → index.BdSLhLDZ.js} +3 -3
- package/dist/chunks/{index.DfviD7lX.js → index.CbWINfS7.js} +49 -21
- package/dist/chunks/{index.BIP7prJq.js → index.CcRZ6fUh.js} +1493 -114
- package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
- package/dist/chunks/{index.C832ioot.js → index.RwjEGCQ0.js} +4 -4
- package/dist/chunks/init-forks.WglB-sfY.js +54 -0
- package/dist/chunks/init-threads.Czek6eA5.js +17 -0
- package/dist/chunks/init.94FWN9pW.js +213 -0
- package/dist/chunks/{inspector.CvQD-Nie.js → inspector.DLZxSeU3.js} +2 -6
- package/dist/chunks/{moduleRunner.d.DxTLreRD.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +9 -14
- package/dist/chunks/{node.CyipiPvJ.js → node.BwAWWjHZ.js} +3 -4
- package/dist/chunks/{plugin.d.CIk0YiKb.d.ts → plugin.d.DQU1R5px.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DmP-iHLr.d.ts → reporters.d.BMKt7f6I.d.ts} +1064 -1021
- package/dist/chunks/{resolveSnapshotEnvironment.Bvv2zr69.js → resolveSnapshotEnvironment.DJJKMKxb.js} +7 -8
- package/dist/chunks/{rpc.BKr6mtxz.js → rpc.cD77ENhU.js} +13 -14
- package/dist/chunks/{setup-common.B7I37Tji.js → setup-common.DR1sucx6.js} +6 -6
- package/dist/chunks/{startModuleRunner.BDRvKSdz.js → startModuleRunner.iF1E9Bt4.js} +126 -110
- package/dist/chunks/{test.BAlBebnP.js → test.C3RPt8JR.js} +7 -7
- package/dist/chunks/{utils.D2R2NiOH.js → utils.CG9h5ccR.js} +2 -5
- package/dist/chunks/{vi.BB37KeLx.js → vi.BZvkKVkM.js} +61 -164
- package/dist/chunks/{vm.CjLTDaST.js → vm.CuMWYx_F.js} +20 -29
- package/dist/chunks/{worker.d.B2r4Ln6p.d.ts → worker.d.BFk-vvBU.d.ts} +42 -6
- package/dist/cli.js +12 -11
- package/dist/config.cjs +0 -1
- package/dist/config.d.ts +11 -13
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +7 -6
- package/dist/coverage.js +3 -14
- package/dist/environments.d.ts +3 -6
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +20 -25
- package/dist/index.js +11 -7
- package/dist/module-evaluator.d.ts +5 -4
- package/dist/module-evaluator.js +11 -13
- package/dist/module-runner.js +5 -5
- package/dist/node.d.ts +82 -25
- package/dist/node.js +23 -20
- package/dist/reporters.d.ts +10 -9
- package/dist/reporters.js +12 -11
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +9 -7
- package/dist/snapshot.js +3 -3
- package/dist/suite.js +4 -3
- package/dist/worker.d.ts +26 -0
- package/dist/worker.js +45 -165
- package/dist/workers/forks.js +26 -43
- package/dist/workers/runVmTests.js +16 -12
- package/dist/workers/threads.js +26 -31
- package/dist/workers/vmForks.js +26 -39
- package/dist/workers/vmThreads.js +26 -29
- package/package.json +48 -32
- package/worker.d.ts +1 -0
- package/browser.d.ts +0 -1
- package/dist/chunks/environment.d.2fYMoz3o.d.ts +0 -66
- package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
- package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
- package/dist/chunks/typechecker.DB-fIMaH.js +0 -805
- package/dist/chunks/utils.C2YI6McM.js +0 -52
- package/dist/chunks/worker.d.DJ6qxO2w.d.ts +0 -8
- package/dist/workers.d.ts +0 -38
- package/dist/workers.js +0 -49
- package/execute.d.ts +0 -1
- package/utils.d.ts +0 -1
- package/workers.d.ts +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _vitest_spy from '@vitest/spy';
|
|
2
2
|
import vm from 'node:vm';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { R as ResolveFunctionResult } from './
|
|
3
|
+
import * as viteModuleRunner from 'vite/module-runner';
|
|
4
|
+
import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode, FetchFunction, EvaluatedModules } from 'vite/module-runner';
|
|
5
|
+
import { R as RuntimeRPC, d as ResolveFunctionResult, W as WorkerGlobalState } from './worker.d.BFk-vvBU.js';
|
|
6
6
|
import { MockedModule, MockedModuleType } from '@vitest/mocker';
|
|
7
7
|
import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './mocker.d.BE_2ls6u.js';
|
|
8
8
|
|
|
@@ -11,11 +11,9 @@ declare class FileMap {
|
|
|
11
11
|
private fsBufferCache;
|
|
12
12
|
readFileAsync(path: string): Promise<string>;
|
|
13
13
|
readFile(path: string): string;
|
|
14
|
-
readBuffer(path: string): Buffer
|
|
14
|
+
readBuffer(path: string): Buffer<ArrayBuffer>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// need to copy paste types for vm
|
|
18
|
-
// because they require latest @types/node which we don't bundle
|
|
19
17
|
interface ModuleEvaluateOptions {
|
|
20
18
|
timeout?: vm.RunningScriptOptions["timeout"] | undefined;
|
|
21
19
|
breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
|
|
@@ -43,7 +41,6 @@ interface ExternalModulesExecutorOptions {
|
|
|
43
41
|
interopDefault?: boolean;
|
|
44
42
|
viteClientModule: Record<string, unknown>;
|
|
45
43
|
}
|
|
46
|
-
// TODO: improve Node.js strict mode support in #2854
|
|
47
44
|
declare class ExternalModulesExecutor {
|
|
48
45
|
#private;
|
|
49
46
|
private options;
|
|
@@ -57,7 +54,6 @@ declare class ExternalModulesExecutor {
|
|
|
57
54
|
import(identifier: string): Promise<object>;
|
|
58
55
|
require(identifier: string): any;
|
|
59
56
|
createRequire(identifier: string): NodeJS.Require;
|
|
60
|
-
// dynamic import can be used in both ESM and CJS, so we have it in the executor
|
|
61
57
|
importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
|
|
62
58
|
resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
|
|
63
59
|
resolve(specifier: string, parent: string): string;
|
|
@@ -155,9 +151,7 @@ declare class VitestMocker {
|
|
|
155
151
|
resolveMocks(): Promise<void>;
|
|
156
152
|
private ensureModule;
|
|
157
153
|
private callFunctionMock;
|
|
158
|
-
// public method to avoid circular dependency
|
|
159
154
|
getMockContext(): MockContext;
|
|
160
|
-
// path used to store mocked dependencies
|
|
161
155
|
getMockPath(dep: string): string;
|
|
162
156
|
getDependencyMock(id: string): MockedModule | undefined;
|
|
163
157
|
findMockRedirect(mockPath: string, external: string | null): string | null;
|
|
@@ -177,12 +171,12 @@ declare module "vite/module-runner" {
|
|
|
177
171
|
}
|
|
178
172
|
}
|
|
179
173
|
|
|
180
|
-
|
|
181
|
-
declare class VitestModuleRunner extends ModuleRunner {
|
|
182
|
-
private
|
|
174
|
+
type CreateImportMeta = NonNullable<viteModuleRunner.ModuleRunnerOptions["createImportMeta"]>;
|
|
175
|
+
declare class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
176
|
+
private vitestOptions;
|
|
183
177
|
mocker: VitestMocker;
|
|
184
178
|
moduleExecutionInfo: ModuleExecutionInfo;
|
|
185
|
-
constructor(
|
|
179
|
+
constructor(vitestOptions: VitestModuleRunnerOptions);
|
|
186
180
|
import(rawId: string): Promise<any>;
|
|
187
181
|
fetchModule(url: string, importer?: string): Promise<EvaluatedModuleNode>;
|
|
188
182
|
private _cachedRequest;
|
|
@@ -195,6 +189,7 @@ interface VitestModuleRunnerOptions {
|
|
|
195
189
|
mocker?: VitestMocker;
|
|
196
190
|
vm?: VitestVmOptions;
|
|
197
191
|
spyModule?: typeof _vitest_spy;
|
|
192
|
+
createImportMeta?: CreateImportMeta;
|
|
198
193
|
}
|
|
199
194
|
interface VitestVmOptions {
|
|
200
195
|
context: vm.Context;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
2
|
-
import { g as getWorkerState } from './utils.
|
|
3
|
-
import '@vitest/utils';
|
|
2
|
+
import { g as getWorkerState } from './utils.CG9h5ccR.js';
|
|
3
|
+
import '@vitest/utils/timers';
|
|
4
4
|
|
|
5
5
|
class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
6
6
|
getHeader() {
|
|
7
7
|
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
8
8
|
}
|
|
9
9
|
resolvePath(filepath) {
|
|
10
|
-
|
|
11
|
-
return rpc.resolveSnapshotPath(filepath);
|
|
10
|
+
return getWorkerState().rpc.resolveSnapshotPath(filepath);
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
|