vitest 1.1.0 → 1.1.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/dist/browser.js +1 -1
- package/dist/child.js +3 -4
- package/dist/chunks/{integrations-globals.8mr2ENps.js → integrations-globals.nOa2-o57.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/entry-vm.js +2 -2
- package/dist/entry.js +2 -2
- package/dist/environments.js +1 -2
- package/dist/execute.d.ts +9 -1
- package/dist/execute.js +1 -1
- package/dist/index.js +3 -3
- package/dist/node.js +3 -3
- package/dist/reporters.js +1 -1
- package/dist/runners.d.ts +2 -3
- package/dist/runners.js +19 -14
- package/dist/vendor/{environments.v4R4vGad.js → environments.QJtma9XQ.js} +6 -7
- package/dist/vendor/{execute.1R_t2FPL.js → execute.vStuEOaI.js} +30 -8
- package/dist/vendor/{index.uQelX_YY.js → index.n6c6aC2Y.js} +1 -1
- package/dist/vendor/{loader.zIj6SiI8.js → loader.L9CYwKn1.js} +1 -1
- package/dist/vendor/{node.i3Lxw5di.js → node.d5m7SYoI.js} +10 -9
- package/dist/vendor/{reporters.r0gTYN3L.js → reporters.oUR9etwS.js} +12 -5
- package/dist/vendor/{vi.pk4NToBt.js → vi.ciwVQ0al.js} +7 -3
- package/dist/vm.js +3 -4
- package/dist/worker.js +3 -4
- package/package.json +7 -7
package/dist/browser.js
CHANGED
|
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
|
|
|
13
13
|
globalSetup = true;
|
|
14
14
|
setSafeTimers();
|
|
15
15
|
if (config.globals)
|
|
16
|
-
(await import('./chunks/integrations-globals.
|
|
16
|
+
(await import('./chunks/integrations-globals.nOa2-o57.js')).registerApiGlobally();
|
|
17
17
|
}
|
|
18
18
|
function setupDefines(defines) {
|
|
19
19
|
for (const key in defines)
|
package/dist/child.js
CHANGED
|
@@ -3,15 +3,14 @@ import v8 from 'node:v8';
|
|
|
3
3
|
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
4
4
|
import { parseRegexp } from '@vitest/utils';
|
|
5
5
|
import { workerId } from 'tinypool';
|
|
6
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
7
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.
|
|
6
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
7
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.vStuEOaI.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
9
9
|
import { s as setupInspect } from './vendor/inspector.lFAeuaAt.js';
|
|
10
10
|
import 'pathe';
|
|
11
11
|
import 'vite-node/client';
|
|
12
|
-
import './vendor/environments.
|
|
12
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
13
13
|
import 'node:console';
|
|
14
|
-
import 'local-pkg';
|
|
15
14
|
import 'node:url';
|
|
16
15
|
import 'node:vm';
|
|
17
16
|
import 'vite-node/utils';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as globalApis } from '../vendor/constants.WSvnD_fn.js';
|
|
2
|
-
import { i as index } from '../vendor/index.
|
|
2
|
+
import { i as index } from '../vendor/index.n6c6aC2Y.js';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import '../vendor/benchmark.WVm6DARl.js';
|
|
5
5
|
import '@vitest/runner/utils';
|
|
@@ -9,7 +9,7 @@ import 'pathe';
|
|
|
9
9
|
import 'std-env';
|
|
10
10
|
import '../vendor/global.L7JRz1qU.js';
|
|
11
11
|
import '../vendor/run-once.X3E7xx3F.js';
|
|
12
|
-
import '../vendor/vi.
|
|
12
|
+
import '../vendor/vi.ciwVQ0al.js';
|
|
13
13
|
import 'chai';
|
|
14
14
|
import '../vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
15
15
|
import '@vitest/expect';
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { normalize } from 'pathe';
|
|
2
2
|
import cac from 'cac';
|
|
3
3
|
import c from 'picocolors';
|
|
4
|
-
import { v as version, s as startVitest } from './vendor/node.
|
|
4
|
+
import { v as version, s as startVitest } from './vendor/node.d5m7SYoI.js';
|
|
5
5
|
import './vendor/index.XU72Rmy8.js';
|
|
6
|
-
import { d as divider } from './vendor/reporters.
|
|
6
|
+
import { d as divider } from './vendor/reporters.oUR9etwS.js';
|
|
7
7
|
import { t as toArray } from './vendor/base._79unx2z.js';
|
|
8
8
|
import 'vite';
|
|
9
9
|
import 'node:path';
|
|
@@ -46,7 +46,7 @@ import 'node:crypto';
|
|
|
46
46
|
import 'assert';
|
|
47
47
|
import 'magic-string';
|
|
48
48
|
import 'strip-literal';
|
|
49
|
-
import './vendor/environments.
|
|
49
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
50
50
|
import 'node:console';
|
|
51
51
|
import 'node:readline';
|
|
52
52
|
import 'readline';
|
package/dist/entry-vm.js
CHANGED
|
@@ -8,7 +8,7 @@ import { setupColors, createColors } from '@vitest/utils';
|
|
|
8
8
|
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor/index.h0j9y5vy.js';
|
|
9
9
|
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
|
|
10
10
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
11
|
-
import { i as index } from './vendor/index.
|
|
11
|
+
import { i as index } from './vendor/index.n6c6aC2Y.js';
|
|
12
12
|
import { setupCommonEnv } from './browser.js';
|
|
13
13
|
import 'chai';
|
|
14
14
|
import '@vitest/snapshot/environment';
|
|
@@ -21,7 +21,7 @@ import '@vitest/runner/utils';
|
|
|
21
21
|
import './vendor/index.XU72Rmy8.js';
|
|
22
22
|
import 'std-env';
|
|
23
23
|
import './vendor/run-once.X3E7xx3F.js';
|
|
24
|
-
import './vendor/vi.
|
|
24
|
+
import './vendor/vi.ciwVQ0al.js';
|
|
25
25
|
import './vendor/_commonjsHelpers.jjO7Zipk.js';
|
|
26
26
|
import '@vitest/expect';
|
|
27
27
|
import '@vitest/snapshot';
|
package/dist/entry.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { startTests } from '@vitest/runner';
|
|
3
3
|
import './vendor/index.XU72Rmy8.js';
|
|
4
|
-
import { a as globalExpect, r as resetModules, v as vi } from './vendor/vi.
|
|
4
|
+
import { a as globalExpect, r as resetModules, v as vi } from './vendor/vi.ciwVQ0al.js';
|
|
5
5
|
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
|
|
6
6
|
import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor/index.h0j9y5vy.js';
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
@@ -10,7 +10,7 @@ import timers from 'node:timers';
|
|
|
10
10
|
import { isatty } from 'node:tty';
|
|
11
11
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
12
12
|
import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
|
|
13
|
-
import { i as index } from './vendor/index.
|
|
13
|
+
import { i as index } from './vendor/index.n6c6aC2Y.js';
|
|
14
14
|
import { setupCommonEnv } from './browser.js';
|
|
15
15
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
16
16
|
import 'pathe';
|
package/dist/environments.js
CHANGED
package/dist/execute.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ import 'node:fs';
|
|
|
16
16
|
import 'chai';
|
|
17
17
|
|
|
18
18
|
type Key = string | symbol;
|
|
19
|
+
interface MockContext {
|
|
20
|
+
/**
|
|
21
|
+
* When mocking with a factory, this refers to the module that imported the mock.
|
|
22
|
+
*/
|
|
23
|
+
callstack: null | string[];
|
|
24
|
+
}
|
|
19
25
|
declare class VitestMocker {
|
|
20
26
|
executor: VitestExecutor;
|
|
21
27
|
static pendingIds: PendingSuiteMock[];
|
|
@@ -23,6 +29,7 @@ declare class VitestMocker {
|
|
|
23
29
|
private resolveCache;
|
|
24
30
|
private primitives;
|
|
25
31
|
private filterPublicKeys;
|
|
32
|
+
private mockContext;
|
|
26
33
|
constructor(executor: VitestExecutor);
|
|
27
34
|
private get root();
|
|
28
35
|
private get mockMap();
|
|
@@ -39,6 +46,7 @@ declare class VitestMocker {
|
|
|
39
46
|
private resolvePath;
|
|
40
47
|
resolveMocks(): Promise<void>;
|
|
41
48
|
private callFunctionMock;
|
|
49
|
+
getMockContext(): MockContext;
|
|
42
50
|
getMockPath(dep: string): string;
|
|
43
51
|
getDependencyMock(id: string): string | MockFactory | null;
|
|
44
52
|
normalizePath(path: string): string;
|
|
@@ -46,7 +54,7 @@ declare class VitestMocker {
|
|
|
46
54
|
mockObject(object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
|
|
47
55
|
unmockPath(path: string): void;
|
|
48
56
|
mockPath(originalId: string, path: string, external: string | null, factory?: MockFactory): void;
|
|
49
|
-
importActual<T>(rawId: string,
|
|
57
|
+
importActual<T>(rawId: string, importer: string, callstack?: string[] | null): Promise<T>;
|
|
50
58
|
importMock(rawId: string, importee: string): Promise<any>;
|
|
51
59
|
requestWithMock(url: string, callstack: string[]): Promise<any>;
|
|
52
60
|
queueMock(id: string, importer: string, factory?: MockFactory): void;
|
package/dist/execute.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
2
|
export { b as bench } from './vendor/benchmark.WVm6DARl.js';
|
|
3
3
|
export { i as isFirstRun, r as runOnce } from './vendor/run-once.X3E7xx3F.js';
|
|
4
|
-
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.
|
|
5
|
-
import { d as dist } from './vendor/index.
|
|
6
|
-
export { c as assertType, g as getRunningMode, a as inject, b as isWatchMode } from './vendor/index.
|
|
4
|
+
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.ciwVQ0al.js';
|
|
5
|
+
import { d as dist } from './vendor/index.n6c6aC2Y.js';
|
|
6
|
+
export { c as assertType, g as getRunningMode, a as inject, b as isWatchMode } from './vendor/index.n6c6aC2Y.js';
|
|
7
7
|
import * as chai from 'chai';
|
|
8
8
|
export { chai };
|
|
9
9
|
export { assert, should } from 'chai';
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BaseSequencer, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/node.
|
|
1
|
+
export { B as BaseSequencer, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/node.d5m7SYoI.js';
|
|
2
2
|
import 'pathe';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'node:path';
|
|
@@ -41,7 +41,7 @@ import 'node:module';
|
|
|
41
41
|
import 'local-pkg';
|
|
42
42
|
import 'module';
|
|
43
43
|
import 'acorn-walk';
|
|
44
|
-
import './vendor/reporters.
|
|
44
|
+
import './vendor/reporters.oUR9etwS.js';
|
|
45
45
|
import './chunks/runtime-console.hf2msWA9.js';
|
|
46
46
|
import 'node:stream';
|
|
47
47
|
import 'node:console';
|
|
@@ -51,6 +51,6 @@ import 'node:crypto';
|
|
|
51
51
|
import 'assert';
|
|
52
52
|
import 'magic-string';
|
|
53
53
|
import 'strip-literal';
|
|
54
|
-
import './vendor/environments.
|
|
54
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
55
55
|
import 'node:readline';
|
|
56
56
|
import 'readline';
|
package/dist/reporters.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, f as DotReporter, H as HangingProcessReporter, g as JUnitReporter, J as JsonReporter, R as ReportersMap, h as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/reporters.
|
|
1
|
+
export { e as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, f as DotReporter, H as HangingProcessReporter, g as JUnitReporter, J as JsonReporter, R as ReportersMap, h as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/reporters.oUR9etwS.js';
|
|
2
2
|
import 'node:perf_hooks';
|
|
3
3
|
import 'picocolors';
|
|
4
4
|
import './vendor/index.XU72Rmy8.js';
|
package/dist/runners.d.ts
CHANGED
|
@@ -23,12 +23,11 @@ declare class VitestTestRunner implements VitestRunner {
|
|
|
23
23
|
constructor(config: ResolvedConfig);
|
|
24
24
|
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
|
25
25
|
onBeforeRunFiles(): void;
|
|
26
|
-
|
|
27
|
-
onAfterRunSuite(suite: Suite): void;
|
|
26
|
+
onAfterRunSuite(suite: Suite): Promise<void>;
|
|
28
27
|
onAfterRunTask(test: Test): void;
|
|
29
28
|
onCancel(_reason: CancelReason): void;
|
|
30
29
|
onBeforeRunTask(test: Test): Promise<void>;
|
|
31
|
-
onBeforeRunSuite(suite: Suite): void
|
|
30
|
+
onBeforeRunSuite(suite: Suite): Promise<void>;
|
|
32
31
|
onBeforeTryTask(test: Test): void;
|
|
33
32
|
onAfterTryTask(test: Test): void;
|
|
34
33
|
extendTaskContext<T extends Test | Custom>(context: TaskContext<T>): ExtendedContext<T>;
|
package/dist/runners.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.ciwVQ0al.js';
|
|
3
3
|
import './vendor/index.XU72Rmy8.js';
|
|
4
4
|
import { a as rpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
5
5
|
import { g as getFullName } from './vendor/tasks.IknbGB2n.js';
|
|
6
6
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
7
|
-
import { getNames } from '@vitest/runner/utils';
|
|
7
|
+
import { getTests, getNames } from '@vitest/runner/utils';
|
|
8
8
|
import { updateTask } from '@vitest/runner';
|
|
9
9
|
import { createDefer, getSafeTimers } from '@vitest/utils';
|
|
10
10
|
import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.WVm6DARl.js';
|
|
@@ -34,14 +34,20 @@ class VitestTestRunner {
|
|
|
34
34
|
onBeforeRunFiles() {
|
|
35
35
|
this.snapshotClient.clear();
|
|
36
36
|
}
|
|
37
|
-
async
|
|
38
|
-
const result = await this.snapshotClient.finishCurrentRun();
|
|
39
|
-
if (result)
|
|
40
|
-
await rpc().snapshotSaved(result);
|
|
41
|
-
}
|
|
42
|
-
onAfterRunSuite(suite) {
|
|
37
|
+
async onAfterRunSuite(suite) {
|
|
43
38
|
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
44
39
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
40
|
+
if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
|
|
41
|
+
for (const test of getTests(suite)) {
|
|
42
|
+
if (test.mode === "skip") {
|
|
43
|
+
const name = getNames(test).slice(1).join(" > ");
|
|
44
|
+
this.snapshotClient.skipTestSnapshots(name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const result = await this.snapshotClient.finishCurrentRun();
|
|
48
|
+
if (result)
|
|
49
|
+
await rpc().snapshotSaved(result);
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
onAfterRunTask(test) {
|
|
47
53
|
this.snapshotClient.clearTest();
|
|
@@ -53,20 +59,19 @@ class VitestTestRunner {
|
|
|
53
59
|
this.cancelRun = true;
|
|
54
60
|
}
|
|
55
61
|
async onBeforeRunTask(test) {
|
|
56
|
-
const name = getNames(test).slice(1).join(" > ");
|
|
57
62
|
if (this.cancelRun)
|
|
58
63
|
test.mode = "skip";
|
|
59
|
-
if (test.mode !== "run")
|
|
60
|
-
this.snapshotClient.skipTestSnapshots(name);
|
|
64
|
+
if (test.mode !== "run")
|
|
61
65
|
return;
|
|
62
|
-
}
|
|
63
66
|
clearModuleMocks(this.config);
|
|
64
|
-
await this.snapshotClient.startCurrentRun(test.file.filepath, name, this.workerState.config.snapshotOptions);
|
|
65
67
|
this.workerState.current = test;
|
|
66
68
|
}
|
|
67
|
-
onBeforeRunSuite(suite) {
|
|
69
|
+
async onBeforeRunSuite(suite) {
|
|
68
70
|
if (this.cancelRun)
|
|
69
71
|
suite.mode = "skip";
|
|
72
|
+
if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
|
|
73
|
+
await this.snapshotClient.startCurrentRun(suite.filepath, "__default_name_", this.workerState.config.snapshotOptions);
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
76
|
onBeforeTryTask(test) {
|
|
72
77
|
var _a;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Console } from 'node:console';
|
|
2
|
-
import { importModule } from 'local-pkg';
|
|
3
2
|
|
|
4
3
|
const denyList = /* @__PURE__ */ new Set([
|
|
5
4
|
"GLOBAL",
|
|
@@ -440,7 +439,7 @@ var jsdom = {
|
|
|
440
439
|
JSDOM,
|
|
441
440
|
ResourceLoader,
|
|
442
441
|
VirtualConsole
|
|
443
|
-
} = await
|
|
442
|
+
} = await import('jsdom');
|
|
444
443
|
const {
|
|
445
444
|
html = "<!DOCTYPE html>",
|
|
446
445
|
userAgent,
|
|
@@ -503,7 +502,7 @@ var jsdom = {
|
|
|
503
502
|
JSDOM,
|
|
504
503
|
ResourceLoader,
|
|
505
504
|
VirtualConsole
|
|
506
|
-
} = await
|
|
505
|
+
} = await import('jsdom');
|
|
507
506
|
const {
|
|
508
507
|
html = "<!DOCTYPE html>",
|
|
509
508
|
userAgent,
|
|
@@ -549,7 +548,7 @@ var happy = {
|
|
|
549
548
|
name: "happy-dom",
|
|
550
549
|
transformMode: "web",
|
|
551
550
|
async setupVM({ happyDOM = {} }) {
|
|
552
|
-
const { Window } = await
|
|
551
|
+
const { Window } = await import('happy-dom');
|
|
553
552
|
const win = new Window({
|
|
554
553
|
...happyDOM,
|
|
555
554
|
console: console && globalThis.console ? globalThis.console : void 0,
|
|
@@ -572,7 +571,7 @@ var happy = {
|
|
|
572
571
|
};
|
|
573
572
|
},
|
|
574
573
|
async setup(global, { happyDOM = {} }) {
|
|
575
|
-
const { Window, GlobalWindow } = await
|
|
574
|
+
const { Window, GlobalWindow } = await import('happy-dom');
|
|
576
575
|
const win = new (GlobalWindow || Window)({
|
|
577
576
|
...happyDOM,
|
|
578
577
|
console: console && global.console ? global.console : void 0,
|
|
@@ -601,7 +600,7 @@ var edge = {
|
|
|
601
600
|
name: "edge-runtime",
|
|
602
601
|
transformMode: "ssr",
|
|
603
602
|
async setupVM() {
|
|
604
|
-
const { EdgeVM } = await
|
|
603
|
+
const { EdgeVM } = await import('@edge-runtime/vm');
|
|
605
604
|
const vm = new EdgeVM({
|
|
606
605
|
extend: (context) => {
|
|
607
606
|
context.global = context;
|
|
@@ -618,7 +617,7 @@ var edge = {
|
|
|
618
617
|
};
|
|
619
618
|
},
|
|
620
619
|
async setup(global) {
|
|
621
|
-
const { EdgeVM } = await
|
|
620
|
+
const { EdgeVM } = await import('@edge-runtime/vm');
|
|
622
621
|
const vm = new EdgeVM({
|
|
623
622
|
extend: (context) => {
|
|
624
623
|
context.global = context;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
2
2
|
import vm from 'node:vm';
|
|
3
3
|
import { ModuleCacheMap, ViteNodeRunner, DEFAULT_REQUEST_STUBS } from 'vite-node/client';
|
|
4
|
-
import { isNodeBuiltin, isPrimitive, toArray, getCachedData, setCacheData, isInternalRequest } from 'vite-node/utils';
|
|
4
|
+
import { isNodeBuiltin, isPrimitive, toArray, getCachedData, setCacheData, isInternalRequest, toFilePath } from 'vite-node/utils';
|
|
5
5
|
import { resolve, isAbsolute, dirname, join, basename, extname, normalize, relative } from 'pathe';
|
|
6
6
|
import { processError } from '@vitest/utils/error';
|
|
7
7
|
import { distDir } from '../paths.js';
|
|
@@ -48,6 +48,9 @@ class VitestMocker {
|
|
|
48
48
|
resolveCache = /* @__PURE__ */ new Map();
|
|
49
49
|
primitives;
|
|
50
50
|
filterPublicKeys;
|
|
51
|
+
mockContext = {
|
|
52
|
+
callstack: null
|
|
53
|
+
};
|
|
51
54
|
get root() {
|
|
52
55
|
return this.executor.options.root;
|
|
53
56
|
}
|
|
@@ -151,10 +154,10 @@ class VitestMocker {
|
|
|
151
154
|
const c = getColors();
|
|
152
155
|
throw this.createError(
|
|
153
156
|
`[vitest] No "${String(prop)}" export is defined on the "${mockpath}" mock. Did you forget to return it from "vi.mock"?
|
|
154
|
-
If you need to partially mock a module, you can use "
|
|
157
|
+
If you need to partially mock a module, you can use "importOriginal" helper inside:
|
|
155
158
|
|
|
156
|
-
${c.green(`vi.mock("${mockpath}", async () => {
|
|
157
|
-
const actual = await
|
|
159
|
+
${c.green(`vi.mock("${mockpath}", async (importOriginal) => {
|
|
160
|
+
const actual = await importOriginal()
|
|
158
161
|
return {
|
|
159
162
|
...actual,
|
|
160
163
|
// your mocked methods
|
|
@@ -169,6 +172,9 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
169
172
|
this.moduleCache.set(dep, { exports: moduleExports });
|
|
170
173
|
return moduleExports;
|
|
171
174
|
}
|
|
175
|
+
getMockContext() {
|
|
176
|
+
return this.mockContext;
|
|
177
|
+
}
|
|
172
178
|
getMockPath(dep) {
|
|
173
179
|
return `mock:${dep}`;
|
|
174
180
|
}
|
|
@@ -303,9 +309,9 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
303
309
|
this.resolveCache.set(suitefile, resolves);
|
|
304
310
|
this.deleteCachedItem(id);
|
|
305
311
|
}
|
|
306
|
-
async importActual(rawId,
|
|
307
|
-
const { id, fsPath } = await this.resolvePath(rawId,
|
|
308
|
-
const result = await this.executor.cachedRequest(id, fsPath, [
|
|
312
|
+
async importActual(rawId, importer, callstack) {
|
|
313
|
+
const { id, fsPath } = await this.resolvePath(rawId, importer);
|
|
314
|
+
const result = await this.executor.cachedRequest(id, fsPath, callstack || [importer]);
|
|
309
315
|
return result;
|
|
310
316
|
}
|
|
311
317
|
async importMock(rawId, importee) {
|
|
@@ -339,8 +345,10 @@ ${c.green(`vi.mock("${mockpath}", async () => {
|
|
|
339
345
|
if (typeof mock === "function" && !callstack.includes(mockPath) && !callstack.includes(url)) {
|
|
340
346
|
try {
|
|
341
347
|
callstack.push(mockPath);
|
|
348
|
+
this.mockContext.callstack = callstack;
|
|
342
349
|
return await this.callFunctionMock(mockPath, mock);
|
|
343
350
|
} finally {
|
|
351
|
+
this.mockContext.callstack = null;
|
|
344
352
|
const indexMock = callstack.indexOf(mockPath);
|
|
345
353
|
callstack.splice(indexMock, 1);
|
|
346
354
|
}
|
|
@@ -998,6 +1006,7 @@ const packageCache = /* @__PURE__ */ new Map();
|
|
|
998
1006
|
const moduleCache = new ModuleCacheMap();
|
|
999
1007
|
const mockMap = /* @__PURE__ */ new Map();
|
|
1000
1008
|
const fileMap = new FileMap();
|
|
1009
|
+
const externalizeMap = /* @__PURE__ */ new Map();
|
|
1001
1010
|
async function startViteNode(options) {
|
|
1002
1011
|
if (_viteNode)
|
|
1003
1012
|
return _viteNode;
|
|
@@ -1006,6 +1015,7 @@ async function startViteNode(options) {
|
|
|
1006
1015
|
_viteNode = { run, executor };
|
|
1007
1016
|
return _viteNode;
|
|
1008
1017
|
}
|
|
1018
|
+
const bareVitestRegexp = /^@?vitest(\/|$)/;
|
|
1009
1019
|
async function startVitestExecutor(options) {
|
|
1010
1020
|
const state = () => globalThis.__vitest_worker__ || options.state;
|
|
1011
1021
|
const rpc = () => state().rpc;
|
|
@@ -1034,7 +1044,19 @@ async function startVitestExecutor(options) {
|
|
|
1034
1044
|
return state().environment.transformMode ?? "ssr";
|
|
1035
1045
|
};
|
|
1036
1046
|
return await createVitestExecutor({
|
|
1037
|
-
fetchModule(id) {
|
|
1047
|
+
async fetchModule(id) {
|
|
1048
|
+
if (externalizeMap.has(id))
|
|
1049
|
+
return { externalize: externalizeMap.get(id) };
|
|
1050
|
+
if (id.includes(distDir)) {
|
|
1051
|
+
const { path } = toFilePath(id, state().config.root);
|
|
1052
|
+
const externalize = pathToFileURL(path).toString();
|
|
1053
|
+
externalizeMap.set(id, externalize);
|
|
1054
|
+
return { externalize };
|
|
1055
|
+
}
|
|
1056
|
+
if (bareVitestRegexp.test(id)) {
|
|
1057
|
+
externalizeMap.set(id, id);
|
|
1058
|
+
return { externalize: id };
|
|
1059
|
+
}
|
|
1038
1060
|
return rpc().fetch(id, getTransformMode());
|
|
1039
1061
|
},
|
|
1040
1062
|
resolveId(id, importer) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
2
|
import { b as bench } from './benchmark.WVm6DARl.js';
|
|
3
3
|
import { i as isFirstRun, r as runOnce } from './run-once.X3E7xx3F.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.ciwVQ0al.js';
|
|
5
5
|
import { g as getWorkerState } from './global.L7JRz1qU.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
import { assert, should } from 'chai';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve, normalize } from 'pathe';
|
|
2
2
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
3
|
-
import { e as environments } from './environments.
|
|
3
|
+
import { e as environments } from './environments.QJtma9XQ.js';
|
|
4
4
|
|
|
5
5
|
function isBuiltinEnvironment(env) {
|
|
6
6
|
return env in environments;
|
|
@@ -39,12 +39,12 @@ import { isCI, provider as provider$1 } from 'std-env';
|
|
|
39
39
|
import ge from 'module';
|
|
40
40
|
import { ancestor, simple, findNodeAround } from 'acorn-walk';
|
|
41
41
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed } from '@vitest/runner/utils';
|
|
42
|
-
import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.
|
|
42
|
+
import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.oUR9etwS.js';
|
|
43
43
|
import crypto, { createHash } from 'node:crypto';
|
|
44
44
|
import require$$0$3 from 'assert';
|
|
45
45
|
import MagicString from 'magic-string';
|
|
46
46
|
import { stripLiteral } from 'strip-literal';
|
|
47
|
-
import { g as getEnvPackageName } from './environments.
|
|
47
|
+
import { g as getEnvPackageName } from './environments.QJtma9XQ.js';
|
|
48
48
|
import readline from 'node:readline';
|
|
49
49
|
import require$$0$4 from 'readline';
|
|
50
50
|
|
|
@@ -63,7 +63,7 @@ function _mergeNamespaces(n, m) {
|
|
|
63
63
|
return Object.freeze(n);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
var version$1 = "1.1.
|
|
66
|
+
var version$1 = "1.1.1";
|
|
67
67
|
|
|
68
68
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
69
69
|
async function ensurePackageInstalled(dependency, root) {
|
|
@@ -3299,7 +3299,7 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
|
3299
3299
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3300
3300
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3301
3301
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3302
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3302
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3303
3303
|
else
|
|
3304
3304
|
throw error;
|
|
3305
3305
|
} finally {
|
|
@@ -3452,7 +3452,7 @@ function createThreadsPool(ctx, { execArgv, env, workerPath }) {
|
|
|
3452
3452
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3453
3453
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3454
3454
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3455
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3455
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3456
3456
|
else
|
|
3457
3457
|
throw error;
|
|
3458
3458
|
} finally {
|
|
@@ -3566,7 +3566,7 @@ function createBrowserPool(ctx) {
|
|
|
3566
3566
|
if (project.config.browser.isolate) {
|
|
3567
3567
|
for (const path of paths) {
|
|
3568
3568
|
if (isCancelled) {
|
|
3569
|
-
ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.
|
|
3569
|
+
ctx.state.cancelFiles(files.slice(paths.indexOf(path)), ctx.config.root, project.config.name);
|
|
3570
3570
|
break;
|
|
3571
3571
|
}
|
|
3572
3572
|
const url = new URL("/", origin);
|
|
@@ -3741,7 +3741,7 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
|
3741
3741
|
if (error instanceof Error && /Failed to terminate worker/.test(error.message))
|
|
3742
3742
|
ctx.state.addProcessTimeoutCause(`Failed to terminate worker while running ${files.join(", ")}.`);
|
|
3743
3743
|
else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message))
|
|
3744
|
-
ctx.state.cancelFiles(files, ctx.config.root, project.
|
|
3744
|
+
ctx.state.cancelFiles(files, ctx.config.root, project.config.name);
|
|
3745
3745
|
else
|
|
3746
3746
|
throw error;
|
|
3747
3747
|
} finally {
|
|
@@ -3750,6 +3750,7 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
|
3750
3750
|
}
|
|
3751
3751
|
}
|
|
3752
3752
|
return async (specs, invalidates) => {
|
|
3753
|
+
ctx.onCancel(() => pool.cancelPendingTasks());
|
|
3753
3754
|
const configs = /* @__PURE__ */ new Map();
|
|
3754
3755
|
const getConfig = (project) => {
|
|
3755
3756
|
if (configs.has(project))
|
|
@@ -5055,7 +5056,7 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
5055
5056
|
const isSingleFork = resolved.pool === "forks" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.forks) == null ? void 0 : _e.singleFork);
|
|
5056
5057
|
if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
|
|
5057
5058
|
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
5058
|
-
throw new Error(`You cannot use ${inspectOption} without "--no-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
5059
|
+
throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
5059
5060
|
}
|
|
5060
5061
|
}
|
|
5061
5062
|
if (resolved.coverage.provider === "c8")
|
|
@@ -6478,7 +6479,7 @@ createLogUpdate(process$2.stdout);
|
|
|
6478
6479
|
|
|
6479
6480
|
createLogUpdate(process$2.stderr);
|
|
6480
6481
|
|
|
6481
|
-
var version = "1.1.
|
|
6482
|
+
var version = "1.1.1";
|
|
6482
6483
|
|
|
6483
6484
|
async function printError(error, project, options) {
|
|
6484
6485
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
@@ -1949,7 +1949,7 @@ let JsonReporter$1 = class JsonReporter {
|
|
|
1949
1949
|
success,
|
|
1950
1950
|
testResults
|
|
1951
1951
|
};
|
|
1952
|
-
await this.writeReport(JSON.stringify(result
|
|
1952
|
+
await this.writeReport(JSON.stringify(result));
|
|
1953
1953
|
}
|
|
1954
1954
|
async onFinished(files = this.ctx.state.getFiles()) {
|
|
1955
1955
|
await this.logTasks(files);
|
|
@@ -2253,13 +2253,13 @@ class JUnitReporter {
|
|
|
2253
2253
|
var _a;
|
|
2254
2254
|
await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
|
|
2255
2255
|
const transformed = files.map((file) => {
|
|
2256
|
-
var _a2;
|
|
2256
|
+
var _a2, _b;
|
|
2257
2257
|
const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
|
|
2258
2258
|
const stats2 = tasks.reduce((stats3, task) => {
|
|
2259
|
-
var _a3,
|
|
2259
|
+
var _a3, _b2;
|
|
2260
2260
|
return {
|
|
2261
2261
|
passed: stats3.passed + Number(((_a3 = task.result) == null ? void 0 : _a3.state) === "pass"),
|
|
2262
|
-
failures: stats3.failures + Number(((
|
|
2262
|
+
failures: stats3.failures + Number(((_b2 = task.result) == null ? void 0 : _b2.state) === "fail"),
|
|
2263
2263
|
skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
|
|
2264
2264
|
};
|
|
2265
2265
|
}, {
|
|
@@ -2267,7 +2267,14 @@ class JUnitReporter {
|
|
|
2267
2267
|
failures: 0,
|
|
2268
2268
|
skipped: 0
|
|
2269
2269
|
});
|
|
2270
|
-
|
|
2270
|
+
const suites = getSuites(file);
|
|
2271
|
+
for (const suite of suites) {
|
|
2272
|
+
if ((_a2 = suite.result) == null ? void 0 : _a2.errors) {
|
|
2273
|
+
tasks.push(suite);
|
|
2274
|
+
stats2.failures += 1;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
if (tasks.length === 0 && ((_b = file.result) == null ? void 0 : _b.state) === "fail") {
|
|
2271
2278
|
stats2.failures = 1;
|
|
2272
2279
|
tasks.push({
|
|
2273
2280
|
id: file.id,
|
|
@@ -3406,7 +3406,7 @@ function createVitest() {
|
|
|
3406
3406
|
_mocker.queueMock(
|
|
3407
3407
|
path,
|
|
3408
3408
|
importer,
|
|
3409
|
-
factory ? () => factory(() => _mocker.importActual(path, importer)) : void 0
|
|
3409
|
+
factory ? () => factory(() => _mocker.importActual(path, importer, _mocker.getMockContext().callstack)) : void 0
|
|
3410
3410
|
);
|
|
3411
3411
|
},
|
|
3412
3412
|
unmock(path) {
|
|
@@ -3417,14 +3417,18 @@ function createVitest() {
|
|
|
3417
3417
|
_mocker.queueMock(
|
|
3418
3418
|
path,
|
|
3419
3419
|
importer,
|
|
3420
|
-
factory ? () => factory(() => _mocker.importActual(path, importer)) : void 0
|
|
3420
|
+
factory ? () => factory(() => _mocker.importActual(path, importer, _mocker.getMockContext().callstack)) : void 0
|
|
3421
3421
|
);
|
|
3422
3422
|
},
|
|
3423
3423
|
doUnmock(path) {
|
|
3424
3424
|
_mocker.queueUnmock(path, getImporter());
|
|
3425
3425
|
},
|
|
3426
3426
|
async importActual(path) {
|
|
3427
|
-
return _mocker.importActual(
|
|
3427
|
+
return _mocker.importActual(
|
|
3428
|
+
path,
|
|
3429
|
+
getImporter(),
|
|
3430
|
+
_mocker.getMockContext().callstack
|
|
3431
|
+
);
|
|
3428
3432
|
},
|
|
3429
3433
|
async importMock(path) {
|
|
3430
3434
|
return _mocker.importMock(path, getImporter());
|
package/dist/vm.js
CHANGED
|
@@ -7,13 +7,12 @@ import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
|
7
7
|
import { resolve } from 'pathe';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
9
|
import { distDir } from './paths.js';
|
|
10
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
11
|
-
import { b as startVitestExecutor } from './vendor/execute.
|
|
10
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
11
|
+
import { b as startVitestExecutor } from './vendor/execute.vStuEOaI.js';
|
|
12
12
|
import { createCustomConsole } from './chunks/runtime-console.hf2msWA9.js';
|
|
13
13
|
import { c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
14
|
-
import './vendor/environments.
|
|
14
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
15
15
|
import 'node:console';
|
|
16
|
-
import 'local-pkg';
|
|
17
16
|
import 'vite-node/utils';
|
|
18
17
|
import '@vitest/utils/error';
|
|
19
18
|
import 'node:fs';
|
package/dist/worker.js
CHANGED
|
@@ -2,15 +2,14 @@ import { performance } from 'node:perf_hooks';
|
|
|
2
2
|
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
4
|
import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
|
|
5
|
-
import { l as loadEnvironment } from './vendor/loader.
|
|
6
|
-
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.
|
|
5
|
+
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
6
|
+
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.vStuEOaI.js';
|
|
7
7
|
import { s as setupInspect } from './vendor/inspector.lFAeuaAt.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
9
9
|
import 'pathe';
|
|
10
10
|
import 'vite-node/client';
|
|
11
|
-
import './vendor/environments.
|
|
11
|
+
import './vendor/environments.QJtma9XQ.js';
|
|
12
12
|
import 'node:console';
|
|
13
|
-
import 'local-pkg';
|
|
14
13
|
import 'node:url';
|
|
15
14
|
import 'node:vm';
|
|
16
15
|
import 'vite-node/utils';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -147,12 +147,12 @@
|
|
|
147
147
|
"tinypool": "^0.8.1",
|
|
148
148
|
"vite": "^5.0.0",
|
|
149
149
|
"why-is-node-running": "^2.2.2",
|
|
150
|
-
"@vitest/
|
|
151
|
-
"@vitest/
|
|
152
|
-
"@vitest/
|
|
153
|
-
"@vitest/
|
|
154
|
-
"@vitest/
|
|
155
|
-
"vite-node": "1.1.
|
|
150
|
+
"@vitest/snapshot": "1.1.1",
|
|
151
|
+
"@vitest/spy": "1.1.1",
|
|
152
|
+
"@vitest/utils": "1.1.1",
|
|
153
|
+
"@vitest/runner": "1.1.1",
|
|
154
|
+
"@vitest/expect": "1.1.1",
|
|
155
|
+
"vite-node": "1.1.1"
|
|
156
156
|
},
|
|
157
157
|
"devDependencies": {
|
|
158
158
|
"@ampproject/remapping": "^2.2.1",
|