vitest 4.0.11 → 4.0.13
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/dist/browser.d.ts +7 -11
- package/dist/chunks/{base.DiCUKpyF.js → base.Dqf2QAxh.js} +2 -2
- package/dist/chunks/{browser.d.D-d8eZY4.d.ts → browser.d.CDvMh6F9.d.ts} +1 -1
- package/dist/chunks/{cac.aVhqBj0-.js → cac.L-UbQ_Ix.js} +3 -3
- package/dist/chunks/{cli-api.-bIZD4XU.js → cli-api.CdZ6wo9-.js} +63 -57
- package/dist/chunks/{traces.d.B8ukBJqA.d.ts → config.d.g6OOauRt.d.ts} +1 -33
- package/dist/chunks/{global.d.uY4Q0M5z.d.ts → global.d.B15mdLcR.d.ts} +1 -1
- package/dist/chunks/{init-forks.DIuGPyId.js → init-forks.CglOH45c.js} +1 -1
- package/dist/chunks/{init-threads.jC_8JdoN.js → init-threads.BuMdIy1r.js} +1 -1
- package/dist/chunks/{init.B3IeC_yW.js → init.MkYs5nmh.js} +2 -2
- package/dist/chunks/{plugin.d.N8khPRFb.d.ts → plugin.d.B4l3vYM_.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DgZLBdyd.d.ts → reporters.d.J2RlBlp9.d.ts} +5 -3
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/{startModuleRunner.DaBMy1JT.js → startModuleRunner.W28wBIgJ.js} +4 -1
- package/dist/chunks/{traces.BVPrsYso.js → traces.U4xDYhzZ.js} +21 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/{vm.BKyGp1KW.js → vm.Y19jrZy2.js} +2 -2
- package/dist/chunks/{worker.d.B_PZTrCQ.d.ts → worker.d.DCy61tzi.d.ts} +5 -64
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +10 -9
- package/dist/coverage.d.ts +8 -7
- package/dist/index.d.ts +16 -10
- package/dist/module-evaluator.d.ts +117 -13
- package/dist/module-evaluator.js +1 -1
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +10 -9
- package/dist/node.js +4 -4
- package/dist/reporters.d.ts +10 -9
- package/dist/runners.d.ts +2 -2
- package/dist/worker.d.ts +6 -5
- package/dist/worker.js +4 -4
- package/dist/workers/forks.js +5 -5
- package/dist/workers/threads.js +5 -5
- package/dist/workers/vmForks.js +5 -5
- package/dist/workers/vmThreads.js +5 -5
- package/package.json +12 -12
- package/dist/chunks/mocker.d.BE_2ls6u.d.ts +0 -17
- package/dist/chunks/moduleRunner.d.B5SW5pMI.d.ts +0 -208
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { w as workerInit } from '../chunks/init-forks.
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
3
|
-
import '../chunks/init.
|
|
1
|
+
import { w as workerInit } from '../chunks/init-forks.CglOH45c.js';
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.Y19jrZy2.js';
|
|
3
|
+
import '../chunks/init.MkYs5nmh.js';
|
|
4
4
|
import 'node:fs';
|
|
5
5
|
import 'node:module';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
import 'pathe';
|
|
8
8
|
import 'vite/module-runner';
|
|
9
|
-
import '../chunks/startModuleRunner.
|
|
9
|
+
import '../chunks/startModuleRunner.W28wBIgJ.js';
|
|
10
10
|
import '@vitest/utils/helpers';
|
|
11
11
|
import '../path.js';
|
|
12
12
|
import 'node:path';
|
|
13
13
|
import '@vitest/utils/serialize';
|
|
14
14
|
import '../module-evaluator.js';
|
|
15
15
|
import 'node:vm';
|
|
16
|
-
import '../chunks/traces.
|
|
16
|
+
import '../chunks/traces.U4xDYhzZ.js';
|
|
17
17
|
import '@vitest/mocker';
|
|
18
18
|
import '../chunks/index.QWbK7rHY.js';
|
|
19
19
|
import 'node:console';
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { w as workerInit } from '../chunks/init-threads.
|
|
2
|
-
import { r as runVmTests } from '../chunks/vm.
|
|
1
|
+
import { w as workerInit } from '../chunks/init-threads.BuMdIy1r.js';
|
|
2
|
+
import { r as runVmTests } from '../chunks/vm.Y19jrZy2.js';
|
|
3
3
|
import 'node:worker_threads';
|
|
4
|
-
import '../chunks/init.
|
|
4
|
+
import '../chunks/init.MkYs5nmh.js';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'node:module';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'pathe';
|
|
9
9
|
import 'vite/module-runner';
|
|
10
|
-
import '../chunks/startModuleRunner.
|
|
10
|
+
import '../chunks/startModuleRunner.W28wBIgJ.js';
|
|
11
11
|
import '@vitest/utils/helpers';
|
|
12
12
|
import '../path.js';
|
|
13
13
|
import 'node:path';
|
|
14
14
|
import '@vitest/utils/serialize';
|
|
15
15
|
import '../module-evaluator.js';
|
|
16
16
|
import 'node:vm';
|
|
17
|
-
import '../chunks/traces.
|
|
17
|
+
import '../chunks/traces.U4xDYhzZ.js';
|
|
18
18
|
import '@vitest/mocker';
|
|
19
19
|
import '../chunks/index.QWbK7rHY.js';
|
|
20
20
|
import 'node:console';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.13",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -135,10 +135,10 @@
|
|
|
135
135
|
"@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0",
|
|
136
136
|
"happy-dom": "*",
|
|
137
137
|
"jsdom": "*",
|
|
138
|
-
"@vitest/browser-
|
|
139
|
-
"@vitest/browser-
|
|
140
|
-
"@vitest/browser-
|
|
141
|
-
"@vitest/ui": "4.0.
|
|
138
|
+
"@vitest/browser-playwright": "4.0.13",
|
|
139
|
+
"@vitest/browser-preview": "4.0.13",
|
|
140
|
+
"@vitest/browser-webdriverio": "4.0.13",
|
|
141
|
+
"@vitest/ui": "4.0.13"
|
|
142
142
|
},
|
|
143
143
|
"peerDependenciesMeta": {
|
|
144
144
|
"@edge-runtime/vm": {
|
|
@@ -186,13 +186,13 @@
|
|
|
186
186
|
"tinyrainbow": "^3.0.3",
|
|
187
187
|
"vite": "^6.0.0 || ^7.0.0",
|
|
188
188
|
"why-is-node-running": "^2.3.0",
|
|
189
|
-
"@vitest/
|
|
190
|
-
"@vitest/pretty-format": "4.0.
|
|
191
|
-
"@vitest/
|
|
192
|
-
"@vitest/
|
|
193
|
-
"@vitest/
|
|
194
|
-
"@vitest/
|
|
195
|
-
"@vitest/
|
|
189
|
+
"@vitest/mocker": "4.0.13",
|
|
190
|
+
"@vitest/pretty-format": "4.0.13",
|
|
191
|
+
"@vitest/runner": "4.0.13",
|
|
192
|
+
"@vitest/spy": "4.0.13",
|
|
193
|
+
"@vitest/utils": "4.0.13",
|
|
194
|
+
"@vitest/snapshot": "4.0.13",
|
|
195
|
+
"@vitest/expect": "4.0.13"
|
|
196
196
|
},
|
|
197
197
|
"devDependencies": {
|
|
198
198
|
"@antfu/install-pkg": "^1.1.0",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MockedModuleType } from '@vitest/mocker';
|
|
2
|
-
|
|
3
|
-
type Promisable<T> = T | Promise<T>;
|
|
4
|
-
type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M = M>() => Promise<T>) => Promisable<Partial<M>>;
|
|
5
|
-
type MockFactory = () => any;
|
|
6
|
-
interface MockOptions {
|
|
7
|
-
spy?: boolean;
|
|
8
|
-
}
|
|
9
|
-
interface PendingSuiteMock {
|
|
10
|
-
id: string;
|
|
11
|
-
importer: string;
|
|
12
|
-
action: "mock" | "unmock";
|
|
13
|
-
type?: MockedModuleType;
|
|
14
|
-
factory?: MockFactory;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type { MockFactoryWithHelper as M, PendingSuiteMock as P, MockOptions as a, MockFactory as b };
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import * as _vitest_spy from '@vitest/spy';
|
|
2
|
-
import vm from 'node:vm';
|
|
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, e as ResolveFunctionResult, W as WorkerGlobalState } from './worker.d.B_PZTrCQ.js';
|
|
6
|
-
import { T as Traces } from './traces.d.B8ukBJqA.js';
|
|
7
|
-
import { MockedModule, MockedModuleType } from '@vitest/mocker';
|
|
8
|
-
import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './mocker.d.BE_2ls6u.js';
|
|
9
|
-
|
|
10
|
-
declare class FileMap {
|
|
11
|
-
private fsCache;
|
|
12
|
-
private fsBufferCache;
|
|
13
|
-
readFileAsync(path: string): Promise<string>;
|
|
14
|
-
readFile(path: string): string;
|
|
15
|
-
readBuffer(path: string): Buffer<ArrayBuffer>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface ModuleEvaluateOptions {
|
|
19
|
-
timeout?: vm.RunningScriptOptions["timeout"] | undefined;
|
|
20
|
-
breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
|
|
21
|
-
}
|
|
22
|
-
type ModuleLinker = (specifier: string, referencingModule: VMModule, extra: {
|
|
23
|
-
assert: object;
|
|
24
|
-
}) => VMModule | Promise<VMModule>;
|
|
25
|
-
type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
|
|
26
|
-
declare class VMModule {
|
|
27
|
-
dependencySpecifiers: readonly string[];
|
|
28
|
-
error: any;
|
|
29
|
-
identifier: string;
|
|
30
|
-
context: vm.Context;
|
|
31
|
-
namespace: object;
|
|
32
|
-
status: ModuleStatus;
|
|
33
|
-
evaluate(options?: ModuleEvaluateOptions): Promise<void>;
|
|
34
|
-
link(linker: ModuleLinker): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface ExternalModulesExecutorOptions {
|
|
38
|
-
context: vm.Context;
|
|
39
|
-
fileMap: FileMap;
|
|
40
|
-
packageCache: Map<string, any>;
|
|
41
|
-
transform: RuntimeRPC["transform"];
|
|
42
|
-
interopDefault?: boolean;
|
|
43
|
-
viteClientModule: Record<string, unknown>;
|
|
44
|
-
}
|
|
45
|
-
declare class ExternalModulesExecutor {
|
|
46
|
-
#private;
|
|
47
|
-
private options;
|
|
48
|
-
private cjs;
|
|
49
|
-
private esm;
|
|
50
|
-
private vite;
|
|
51
|
-
private context;
|
|
52
|
-
private fs;
|
|
53
|
-
private resolvers;
|
|
54
|
-
constructor(options: ExternalModulesExecutorOptions);
|
|
55
|
-
import(identifier: string): Promise<object>;
|
|
56
|
-
require(identifier: string): any;
|
|
57
|
-
createRequire(identifier: string): NodeJS.Require;
|
|
58
|
-
importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
|
|
59
|
-
resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
|
|
60
|
-
resolve(specifier: string, parent: string): string;
|
|
61
|
-
private getModuleInformation;
|
|
62
|
-
private createModule;
|
|
63
|
-
private get isNetworkSupported();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type ModuleExecutionInfo = Map<string, ModuleExecutionInfoEntry>;
|
|
67
|
-
interface ModuleExecutionInfoEntry {
|
|
68
|
-
startOffset: number;
|
|
69
|
-
/** The duration that was spent executing the module. */
|
|
70
|
-
duration: number;
|
|
71
|
-
/** The time that was spent executing the module itself and externalized imports. */
|
|
72
|
-
selfTime: number;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
interface VitestModuleEvaluatorOptions {
|
|
76
|
-
interopDefault?: boolean | undefined;
|
|
77
|
-
moduleExecutionInfo?: ModuleExecutionInfo;
|
|
78
|
-
getCurrentTestFilepath?: () => string | undefined;
|
|
79
|
-
compiledFunctionArgumentsNames?: string[];
|
|
80
|
-
compiledFunctionArgumentsValues?: unknown[];
|
|
81
|
-
traces?: Traces;
|
|
82
|
-
}
|
|
83
|
-
declare class VitestModuleEvaluator implements ModuleEvaluator {
|
|
84
|
-
private options;
|
|
85
|
-
stubs: Record<string, any>;
|
|
86
|
-
env: ModuleRunnerImportMeta["env"];
|
|
87
|
-
private vm;
|
|
88
|
-
private compiledFunctionArgumentsNames?;
|
|
89
|
-
private compiledFunctionArgumentsValues;
|
|
90
|
-
private primitives;
|
|
91
|
-
private debug;
|
|
92
|
-
private _otel;
|
|
93
|
-
constructor(vmOptions?: VitestVmOptions | undefined, options?: VitestModuleEvaluatorOptions);
|
|
94
|
-
private convertIdToImportUrl;
|
|
95
|
-
runExternalModule(id: string): Promise<any>;
|
|
96
|
-
runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
|
|
97
|
-
private _runInlinedModule;
|
|
98
|
-
private createRequire;
|
|
99
|
-
private shouldInterop;
|
|
100
|
-
}
|
|
101
|
-
declare function createImportMetaEnvProxy(): ModuleRunnerImportMeta["env"];
|
|
102
|
-
declare function getDefaultRequestStubs(context?: vm.Context): Record<string, any>;
|
|
103
|
-
declare function isPrimitive(v: any): boolean;
|
|
104
|
-
declare function wrapId(id: string): string;
|
|
105
|
-
declare function unwrapId(id: string): string;
|
|
106
|
-
|
|
107
|
-
interface VitestTransportOptions {
|
|
108
|
-
fetchModule: FetchFunction;
|
|
109
|
-
resolveId: (id: string, importer?: string) => Promise<ResolveFunctionResult | null>;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
interface MockContext {
|
|
113
|
-
/**
|
|
114
|
-
* When mocking with a factory, this refers to the module that imported the mock.
|
|
115
|
-
*/
|
|
116
|
-
callstack: null | string[];
|
|
117
|
-
}
|
|
118
|
-
interface VitestMockerOptions {
|
|
119
|
-
context?: vm.Context;
|
|
120
|
-
traces: Traces;
|
|
121
|
-
spyModule?: typeof _vitest_spy;
|
|
122
|
-
root: string;
|
|
123
|
-
moduleDirectories: string[];
|
|
124
|
-
resolveId: (id: string, importer?: string) => Promise<{
|
|
125
|
-
id: string;
|
|
126
|
-
file: string;
|
|
127
|
-
url: string;
|
|
128
|
-
} | null>;
|
|
129
|
-
getCurrentTestFilepath: () => string | undefined;
|
|
130
|
-
}
|
|
131
|
-
declare class VitestMocker {
|
|
132
|
-
moduleRunner: VitestModuleRunner;
|
|
133
|
-
private options;
|
|
134
|
-
static pendingIds: PendingSuiteMock[];
|
|
135
|
-
private spyModule?;
|
|
136
|
-
private primitives;
|
|
137
|
-
private filterPublicKeys;
|
|
138
|
-
private registries;
|
|
139
|
-
private mockContext;
|
|
140
|
-
private _otel;
|
|
141
|
-
constructor(moduleRunner: VitestModuleRunner, options: VitestMockerOptions);
|
|
142
|
-
private get root();
|
|
143
|
-
private get evaluatedModules();
|
|
144
|
-
private get moduleDirectories();
|
|
145
|
-
initializeSpyModule(): Promise<void>;
|
|
146
|
-
private getMockerRegistry;
|
|
147
|
-
reset(): void;
|
|
148
|
-
private invalidateModuleById;
|
|
149
|
-
private isModuleDirectory;
|
|
150
|
-
getSuiteFilepath(): string;
|
|
151
|
-
private createError;
|
|
152
|
-
resolveId(rawId: string, importer?: string): Promise<{
|
|
153
|
-
id: string;
|
|
154
|
-
url: string;
|
|
155
|
-
external: string | null;
|
|
156
|
-
}>;
|
|
157
|
-
resolveMocks(): Promise<void>;
|
|
158
|
-
private ensureModule;
|
|
159
|
-
private callFunctionMock;
|
|
160
|
-
getMockContext(): MockContext;
|
|
161
|
-
getMockPath(dep: string): string;
|
|
162
|
-
getDependencyMock(id: string): MockedModule | undefined;
|
|
163
|
-
findMockRedirect(mockPath: string, external: string | null): string | null;
|
|
164
|
-
mockObject(object: Record<string | symbol, any>, mockExports?: Record<string | symbol, any>, behavior?: "automock" | "autospy"): Record<string | symbol, any>;
|
|
165
|
-
unmockPath(id: string): void;
|
|
166
|
-
mockPath(originalId: string, id: string, url: string, external: string | null, mockType: MockedModuleType | undefined, factory: MockFactory | undefined): void;
|
|
167
|
-
importActual<T>(rawId: string, importer: string, callstack?: string[] | null): Promise<T>;
|
|
168
|
-
importMock(rawId: string, importer: string): Promise<any>;
|
|
169
|
-
requestWithMockedModule(url: string, evaluatedNode: EvaluatedModuleNode, callstack: string[], mock: MockedModule): Promise<any>;
|
|
170
|
-
mockedRequest(url: string, evaluatedNode: EvaluatedModuleNode, callstack: string[]): Promise<any>;
|
|
171
|
-
queueMock(id: string, importer: string, factoryOrOptions?: MockFactory | MockOptions): void;
|
|
172
|
-
queueUnmock(id: string, importer: string): void;
|
|
173
|
-
}
|
|
174
|
-
declare module "vite/module-runner" {
|
|
175
|
-
interface EvaluatedModuleNode {
|
|
176
|
-
mockedExports?: Record<string, any>;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
type CreateImportMeta = NonNullable<viteModuleRunner.ModuleRunnerOptions["createImportMeta"]>;
|
|
181
|
-
declare class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
182
|
-
private vitestOptions;
|
|
183
|
-
mocker: VitestMocker;
|
|
184
|
-
moduleExecutionInfo: ModuleExecutionInfo;
|
|
185
|
-
private _otel;
|
|
186
|
-
constructor(vitestOptions: VitestModuleRunnerOptions);
|
|
187
|
-
import(rawId: string): Promise<any>;
|
|
188
|
-
fetchModule(url: string, importer?: string): Promise<EvaluatedModuleNode>;
|
|
189
|
-
private _cachedRequest;
|
|
190
|
-
}
|
|
191
|
-
interface VitestModuleRunnerOptions {
|
|
192
|
-
transport: VitestTransportOptions;
|
|
193
|
-
evaluator: VitestModuleEvaluator;
|
|
194
|
-
evaluatedModules: EvaluatedModules;
|
|
195
|
-
getWorkerState: () => WorkerGlobalState;
|
|
196
|
-
mocker?: VitestMocker;
|
|
197
|
-
vm?: VitestVmOptions;
|
|
198
|
-
traces?: Traces;
|
|
199
|
-
spyModule?: typeof _vitest_spy;
|
|
200
|
-
createImportMeta?: CreateImportMeta;
|
|
201
|
-
}
|
|
202
|
-
interface VitestVmOptions {
|
|
203
|
-
context: vm.Context;
|
|
204
|
-
externalModulesExecutor: ExternalModulesExecutor;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export { VitestModuleRunner as V, VitestModuleEvaluator as b, createImportMetaEnvProxy as c, getDefaultRequestStubs as g, isPrimitive as i, unwrapId as u, wrapId as w };
|
|
208
|
-
export type { VitestModuleEvaluatorOptions as a };
|