vitest 4.0.0-beta.8 → 4.0.0
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 +26 -9
- package/dist/browser.js +17 -7
- package/dist/chunks/base.CtHM3ryk.js +128 -0
- package/dist/chunks/{benchmark.UW6Ezvxy.js → benchmark.DHKMYAts.js} +2 -2
- package/dist/chunks/{browser.d.DOMmqJQx.d.ts → browser.d.B9iJzZyn.d.ts} +3 -3
- package/dist/chunks/{cac.By1HvRIk.js → cac.B99MQg-w.js} +47 -91
- package/dist/chunks/{cli-api.C-JHgQgp.js → cli-api.PwHwIMss.js} +1544 -310
- package/dist/chunks/{config.d._GBBbReY.d.ts → config.d.u2CUDWwS.d.ts} +6 -19
- package/dist/chunks/{console.B0quX7yH.js → console.CTJL2nuH.js} +4 -6
- package/dist/chunks/{coverage.DarITf6U.js → coverage.FU3w4IrQ.js} +128 -1142
- 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.lgsmH00r.js → globals.BGT_RUsD.js} +12 -9
- package/dist/chunks/{index.BuwjkI-q.js → index.BdSLhLDZ.js} +3 -3
- package/dist/chunks/{index.DfviD7lX.js → index.CbWINfS7.js} +49 -21
- package/dist/chunks/{index.AzwzFtyi.js → index.CcRZ6fUh.js} +1493 -114
- package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
- package/dist/chunks/{index.AR8aAkCC.js → index.RwjEGCQ0.js} +7 -8
- package/dist/chunks/init-forks.DSafeltJ.js +54 -0
- package/dist/chunks/init-threads.SUtZ-067.js +17 -0
- package/dist/chunks/init.B2EESLQM.js +213 -0
- package/dist/chunks/{inspector.CvQD-Nie.js → inspector.DLZxSeU3.js} +2 -6
- package/dist/chunks/{moduleRunner.d.CX4DuqOx.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +12 -14
- package/dist/chunks/{node.BOqcT2jW.js → node.BwAWWjHZ.js} +3 -4
- package/dist/chunks/{plugin.d.CHe6slQs.d.ts → plugin.d.DQU1R5px.d.ts} +1 -1
- package/dist/chunks/{reporters.d.37tJQ2uV.d.ts → reporters.d.BMKt7f6I.d.ts} +1066 -1030
- package/dist/chunks/{index.CsFXYRkW.js → resolveSnapshotEnvironment.DJJKMKxb.js} +18 -24
- package/dist/chunks/{rpc.RpPylpp0.js → rpc.cD77ENhU.js} +13 -14
- package/dist/chunks/{setup-common.hLGRxhC8.js → setup-common.DR1sucx6.js} +8 -8
- package/dist/chunks/{startModuleRunner.C8TW8zTN.js → startModuleRunner.C2tTvmF9.js} +131 -110
- package/dist/chunks/test.C3RPt8JR.js +214 -0
- package/dist/chunks/{utils.C7__0Iv5.js → utils.CG9h5ccR.js} +3 -15
- package/dist/chunks/{vi.BfdOiD4j.js → vi.BZvkKVkM.js} +73 -176
- package/dist/chunks/{vm.BHBje7cC.js → vm.DBeOXrP9.js} +29 -33
- package/dist/chunks/{worker.d.DYlqbejz.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 +12 -14
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +8 -7
- package/dist/coverage.js +3 -14
- package/dist/environments.d.ts +3 -6
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +24 -30
- package/dist/index.js +12 -11
- package/dist/module-evaluator.d.ts +6 -4
- package/dist/module-evaluator.js +14 -16
- package/dist/module-runner.js +5 -5
- package/dist/node.d.ts +83 -27
- package/dist/node.js +23 -20
- package/dist/reporters.d.ts +11 -10
- package/dist/reporters.js +12 -11
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +14 -216
- package/dist/snapshot.js +3 -3
- package/dist/suite.js +4 -3
- package/dist/worker.d.ts +26 -0
- package/dist/worker.js +45 -166
- package/dist/workers/forks.js +41 -35
- package/dist/workers/runVmTests.js +25 -22
- package/dist/workers/threads.js +41 -23
- package/dist/workers/vmForks.js +26 -39
- package/dist/workers/vmThreads.js +26 -29
- package/package.json +48 -35
- package/worker.d.ts +1 -0
- package/browser.d.ts +0 -1
- package/dist/chunks/base.BXI97p6t.js +0 -39
- 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/runBaseTests.D6sfuWBM.js +0 -99
- package/dist/chunks/typechecker.DSo_maXz.js +0 -762
- package/dist/chunks/utils.C2YI6McM.js +0 -52
- package/dist/chunks/worker.d.BKu8cnnX.d.ts +0 -8
- package/dist/workers.d.ts +0 -38
- package/dist/workers.js +0 -31
- package/execute.d.ts +0 -1
- package/utils.d.ts +0 -1
- package/workers.d.ts +0 -1
|
@@ -10,10 +10,7 @@ let inspector, session;
|
|
|
10
10
|
function setupInspect(ctx) {
|
|
11
11
|
const config = ctx.config, isEnabled = config.inspector.enabled;
|
|
12
12
|
if (isEnabled) {
|
|
13
|
-
inspector = __require("node:inspector")
|
|
14
|
-
// Inspector may be open already if "isolate: false" is used
|
|
15
|
-
const isOpen = inspector.url() !== void 0;
|
|
16
|
-
if (!isOpen) {
|
|
13
|
+
if (inspector = __require("node:inspector"), !(inspector.url() !== void 0)) {
|
|
17
14
|
if (inspector.open(config.inspector.port, config.inspector.host, config.inspector.waitForDebugger), config.inspectBrk) {
|
|
18
15
|
const firstTestFile = typeof ctx.files[0] === "string" ? ctx.files[0] : ctx.files[0].filepath;
|
|
19
16
|
// Stop at first test file
|
|
@@ -35,8 +32,7 @@ function closeInspector(config) {
|
|
|
35
32
|
}
|
|
36
33
|
function shouldKeepOpen(config) {
|
|
37
34
|
// In watch mode the inspector can persist re-runs if isolation is disabled and a single worker is used
|
|
38
|
-
|
|
39
|
-
return config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
|
|
35
|
+
return config.watch && config.isolate === false && config.maxWorkers === 1;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
export { closeInspector as c, setupInspect as s };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import * as _vitest_spy from '@vitest/spy';
|
|
1
2
|
import vm from 'node:vm';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
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';
|
|
5
6
|
import { MockedModule, MockedModuleType } from '@vitest/mocker';
|
|
6
7
|
import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './mocker.d.BE_2ls6u.js';
|
|
7
8
|
|
|
@@ -10,11 +11,9 @@ declare class FileMap {
|
|
|
10
11
|
private fsBufferCache;
|
|
11
12
|
readFileAsync(path: string): Promise<string>;
|
|
12
13
|
readFile(path: string): string;
|
|
13
|
-
readBuffer(path: string): Buffer
|
|
14
|
+
readBuffer(path: string): Buffer<ArrayBuffer>;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
// need to copy paste types for vm
|
|
17
|
-
// because they require latest @types/node which we don't bundle
|
|
18
17
|
interface ModuleEvaluateOptions {
|
|
19
18
|
timeout?: vm.RunningScriptOptions["timeout"] | undefined;
|
|
20
19
|
breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
|
|
@@ -42,7 +41,6 @@ interface ExternalModulesExecutorOptions {
|
|
|
42
41
|
interopDefault?: boolean;
|
|
43
42
|
viteClientModule: Record<string, unknown>;
|
|
44
43
|
}
|
|
45
|
-
// TODO: improve Node.js strict mode support in #2854
|
|
46
44
|
declare class ExternalModulesExecutor {
|
|
47
45
|
#private;
|
|
48
46
|
private options;
|
|
@@ -56,7 +54,6 @@ declare class ExternalModulesExecutor {
|
|
|
56
54
|
import(identifier: string): Promise<object>;
|
|
57
55
|
require(identifier: string): any;
|
|
58
56
|
createRequire(identifier: string): NodeJS.Require;
|
|
59
|
-
// dynamic import can be used in both ESM and CJS, so we have it in the executor
|
|
60
57
|
importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
|
|
61
58
|
resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
|
|
62
59
|
resolve(specifier: string, parent: string): string;
|
|
@@ -116,6 +113,7 @@ interface MockContext {
|
|
|
116
113
|
}
|
|
117
114
|
interface VitestMockerOptions {
|
|
118
115
|
context?: vm.Context;
|
|
116
|
+
spyModule?: typeof _vitest_spy;
|
|
119
117
|
root: string;
|
|
120
118
|
moduleDirectories: string[];
|
|
121
119
|
resolveId: (id: string, importer?: string) => Promise<{
|
|
@@ -153,9 +151,7 @@ declare class VitestMocker {
|
|
|
153
151
|
resolveMocks(): Promise<void>;
|
|
154
152
|
private ensureModule;
|
|
155
153
|
private callFunctionMock;
|
|
156
|
-
// public method to avoid circular dependency
|
|
157
154
|
getMockContext(): MockContext;
|
|
158
|
-
// path used to store mocked dependencies
|
|
159
155
|
getMockPath(dep: string): string;
|
|
160
156
|
getDependencyMock(id: string): MockedModule | undefined;
|
|
161
157
|
findMockRedirect(mockPath: string, external: string | null): string | null;
|
|
@@ -175,12 +171,12 @@ declare module "vite/module-runner" {
|
|
|
175
171
|
}
|
|
176
172
|
}
|
|
177
173
|
|
|
178
|
-
|
|
179
|
-
declare class VitestModuleRunner extends ModuleRunner {
|
|
180
|
-
private
|
|
174
|
+
type CreateImportMeta = NonNullable<viteModuleRunner.ModuleRunnerOptions["createImportMeta"]>;
|
|
175
|
+
declare class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
176
|
+
private vitestOptions;
|
|
181
177
|
mocker: VitestMocker;
|
|
182
178
|
moduleExecutionInfo: ModuleExecutionInfo;
|
|
183
|
-
constructor(
|
|
179
|
+
constructor(vitestOptions: VitestModuleRunnerOptions);
|
|
184
180
|
import(rawId: string): Promise<any>;
|
|
185
181
|
fetchModule(url: string, importer?: string): Promise<EvaluatedModuleNode>;
|
|
186
182
|
private _cachedRequest;
|
|
@@ -192,6 +188,8 @@ interface VitestModuleRunnerOptions {
|
|
|
192
188
|
getWorkerState: () => WorkerGlobalState;
|
|
193
189
|
mocker?: VitestMocker;
|
|
194
190
|
vm?: VitestVmOptions;
|
|
191
|
+
spyModule?: typeof _vitest_spy;
|
|
192
|
+
createImportMeta?: CreateImportMeta;
|
|
195
193
|
}
|
|
196
194
|
interface VitestVmOptions {
|
|
197
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
|
|