vitest 1.5.3 → 2.0.0-beta.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 +172 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +4 -4
- package/dist/chunks/environments-node.39w4gmlF.js +19 -0
- package/dist/chunks/{install-pkg.LE8oaA1t.js → install-pkg.DNUmWFkO.js} +2 -2
- package/dist/chunks/integrations-globals.B5Jl0grA.js +31 -0
- package/dist/chunks/{runtime-console.EO5ha7qv.js → runtime-console.CUES-L8X.js} +9 -9
- package/dist/chunks/{runtime-runBaseTests.l6qXp5eU.js → runtime-runBaseTests._dXkRAZc.js} +21 -22
- package/dist/cli.js +3 -3
- package/dist/config.cjs +2 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -3
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +2 -2
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +7 -4
- package/dist/execute.js +3 -3
- package/dist/index.d.ts +770 -21
- package/dist/index.js +12 -12
- package/dist/node.d.ts +2 -2
- package/dist/node.js +21 -22
- package/dist/{reporters-BXNXFKfg.d.ts → reporters-MGvT5U9f.d.ts} +128 -55
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +11 -12
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +17 -18
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +8 -0
- package/dist/{suite-KPWE530F.d.ts → suite-8WAe-urM.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +4 -4
- package/dist/vendor/{base.oIzAvGLe.js → base.VFkIJ66g.js} +3 -3
- package/dist/vendor/{base.Xt0Omgh7.js → base._gnK9Slw.js} +8 -1
- package/dist/vendor/{benchmark.yGkUTKnC.js → benchmark.BNLebNi5.js} +1 -1
- package/dist/vendor/{cac.RDd_SGOd.js → cac.DzKZaJu2.js} +39 -17
- package/dist/vendor/{cli-api.AmIc1Dmz.js → cli-api.DTeni0Qq.js} +3201 -404
- package/dist/vendor/{execute.2_yoIC01.js → execute.CLLNVNnK.js} +8 -3
- package/dist/vendor/{index.Fm6OikHU.js → index.BfoZyXD1.js} +20 -21
- package/dist/vendor/{index.8bPxjt7g.js → index.BpSiYbpB.js} +5 -1
- package/dist/vendor/{index.X7lgIMc_.js → index.CRxYS9H3.js} +586 -230
- package/dist/vendor/{index.QVcwRDVW.js → index.CmILuxzC.js} +8 -6
- package/dist/vendor/{index.xL8XjTLv.js → index.DP-km6lF.js} +1 -1
- package/dist/vendor/{index.SMVOaj7F.js → index._7XLd8Kd.js} +2 -2
- package/dist/vendor/{rpc.joBhAkyK.js → rpc.DRDE9Pu1.js} +2 -2
- package/dist/vendor/{run-once.Olz_Zkd8.js → run-once.DLomgGUH.js} +1 -1
- package/dist/vendor/{setup-common.5nUd4r76.js → setup-common.XeoZAW8t.js} +2 -2
- package/dist/vendor/{tasks.IknbGB2n.js → tasks.WC7M-K-v.js} +4 -1
- package/dist/vendor/{utils.VYmeMh-u.js → utils.D5gGkwyH.js} +1 -1
- package/dist/vendor/{vi.Y_w82WR8.js → vi.ClD3hi7L.js} +23 -10
- package/dist/vendor/{vm.i4FO5N37.js → vm.Bi3bljci.js} +132 -54
- package/dist/worker.js +13 -7
- package/dist/workers/forks.js +6 -6
- package/dist/workers/runVmTests.js +22 -20
- package/dist/workers/threads.js +6 -6
- package/dist/workers/vmForks.js +9 -9
- package/dist/workers/vmThreads.js +9 -9
- package/dist/workers.d.ts +1 -1
- package/dist/workers.js +14 -14
- package/package.json +33 -29
- package/snapshot.d.ts +1 -0
- package/vitest.mjs +1 -1
- package/dist/chunks/integrations-globals.Hr6znn-f.js +0 -31
- package/dist/cli-wrapper.js +0 -119
- /package/dist/chunks/{node-git.Hw101KjS.js → node-git.CCI8evVZ.js} +0 -0
- /package/dist/vendor/{_commonjsHelpers.jjO7Zipk.js → _commonjsHelpers.BFTU3MAI.js} +0 -0
- /package/dist/vendor/{constants.5J7I254_.js → constants.5SOfHUj0.js} +0 -0
- /package/dist/vendor/{coverage.E7sG1b3r.js → coverage.ChSqD-qS.js} +0 -0
- /package/dist/vendor/{date.Ns1pGd_X.js → date.BKM1wewY.js} +0 -0
- /package/dist/vendor/{env.AtSIuHFg.js → env.bmJgw1qP.js} +0 -0
- /package/dist/vendor/{global.CkGT_TMy.js → global.7bFbnyXl.js} +0 -0
- /package/dist/vendor/{index.GVFv9dZ0.js → index.DeR1hhfY.js} +0 -0
- /package/dist/vendor/{inspector.IgLX3ur5.js → inspector.hPQncR7V.js} +0 -0
- /package/dist/vendor/{utils.0uYuCbzo.js → utils.CUjzkRH7.js} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import vm from 'node:vm';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
4
|
import { ViteNodeRunner, DEFAULT_REQUEST_STUBS } from 'vite-node/client';
|
|
4
5
|
import { isNodeBuiltin, isInternalRequest, toFilePath, isPrimitive } from 'vite-node/utils';
|
|
5
6
|
import { resolve, isAbsolute, dirname, join, basename, extname, normalize, relative } from 'pathe';
|
|
6
7
|
import { processError } from '@vitest/utils/error';
|
|
7
8
|
import { distDir } from '../path.js';
|
|
8
|
-
import { existsSync, readdirSync } from 'node:fs';
|
|
9
9
|
import { highlight, getType } from '@vitest/utils';
|
|
10
|
-
import { g as getAllMockableProperties } from './base.
|
|
10
|
+
import { g as getAllMockableProperties } from './base._gnK9Slw.js';
|
|
11
11
|
|
|
12
12
|
const spyModulePath = resolve(distDir, "spy.js");
|
|
13
13
|
class RefTracker {
|
|
@@ -418,7 +418,12 @@ async function startVitestExecutor(options) {
|
|
|
418
418
|
externalizeMap.set(id, id);
|
|
419
419
|
return { externalize: id };
|
|
420
420
|
}
|
|
421
|
-
|
|
421
|
+
const result = await rpc().fetch(id, getTransformMode());
|
|
422
|
+
if (result.id && !result.externalize) {
|
|
423
|
+
const code = readFileSync(result.id, "utf-8");
|
|
424
|
+
return { code };
|
|
425
|
+
}
|
|
426
|
+
return result;
|
|
422
427
|
},
|
|
423
428
|
resolveId(id, importer) {
|
|
424
429
|
return rpc().resolveId(id, importer, getTransformMode());
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import * as chai from 'chai';
|
|
2
|
-
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
3
2
|
import { resolve } from 'pathe';
|
|
4
3
|
import { distDir } from '../path.js';
|
|
5
|
-
import { g as getWorkerState } from './global.
|
|
6
|
-
import { r as rpc } from './rpc.
|
|
7
|
-
import { t as takeCoverageInsideWorker } from './coverage.
|
|
8
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
4
|
+
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
5
|
+
import { r as rpc } from './rpc.DRDE9Pu1.js';
|
|
6
|
+
import { t as takeCoverageInsideWorker } from './coverage.ChSqD-qS.js';
|
|
7
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.XeoZAW8t.js';
|
|
9
8
|
|
|
10
9
|
function setupChaiConfig(config) {
|
|
11
10
|
Object.assign(chai.config, config);
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
getHeader() {
|
|
20
|
-
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
21
|
-
}
|
|
22
|
-
resolvePath(filepath) {
|
|
23
|
-
return this.rpc.resolveSnapshotPath(filepath);
|
|
13
|
+
async function resolveSnapshotEnvironment(config, executor) {
|
|
14
|
+
if (!config.snapshotEnvironment) {
|
|
15
|
+
const { VitestNodeSnapshotEnvironment } = await import('../chunks/environments-node.39w4gmlF.js');
|
|
16
|
+
return new VitestNodeSnapshotEnvironment();
|
|
24
17
|
}
|
|
18
|
+
const mod = await executor.executeId(config.snapshotEnvironment);
|
|
19
|
+
if (typeof mod.default !== "object" || !mod.default)
|
|
20
|
+
throw new Error("Snapshot environment module must have a default export object with a shape of `SnapshotEnvironment`");
|
|
21
|
+
return mod.default;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
const runnersFile = resolve(distDir, "runners.js");
|
|
@@ -74,11 +71,13 @@ async function resolveTestRunner(config, executor) {
|
|
|
74
71
|
testRunner.onAfterRunFiles = async (files) => {
|
|
75
72
|
const state = getWorkerState();
|
|
76
73
|
const coverage = await takeCoverageInsideWorker(config.coverage, executor);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
if (coverage) {
|
|
75
|
+
rpc().onAfterSuiteRun({
|
|
76
|
+
coverage,
|
|
77
|
+
transformMode: state.environment.transformMode,
|
|
78
|
+
projectName: state.ctx.projectName
|
|
79
|
+
});
|
|
80
|
+
}
|
|
82
81
|
await (originalOnAfterRun == null ? void 0 : originalOnAfterRun.call(testRunner, files));
|
|
83
82
|
};
|
|
84
83
|
const originalOnAfterRunTask = testRunner.onAfterRunTask;
|
|
@@ -97,4 +96,4 @@ async function resolveTestRunner(config, executor) {
|
|
|
97
96
|
return testRunner;
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
export {
|
|
99
|
+
export { resolveSnapshotEnvironment as a, resolveTestRunner as r, setupChaiConfig as s };
|
|
@@ -21,6 +21,8 @@ function createBirpc(functions, options) {
|
|
|
21
21
|
get(_, method) {
|
|
22
22
|
if (method === "$functions")
|
|
23
23
|
return functions;
|
|
24
|
+
if (method === "then" && !eventNames.includes("then") && !("then" in functions))
|
|
25
|
+
return void 0;
|
|
24
26
|
const sendEvent = (...args) => {
|
|
25
27
|
post(serialize({ m: method, a: args, t: "q" }));
|
|
26
28
|
};
|
|
@@ -42,7 +44,9 @@ function createBirpc(functions, options) {
|
|
|
42
44
|
reject(e);
|
|
43
45
|
}
|
|
44
46
|
rpcPromiseMap.delete(id);
|
|
45
|
-
}, timeout)
|
|
47
|
+
}, timeout);
|
|
48
|
+
if (typeof timeoutId === "object")
|
|
49
|
+
timeoutId = timeoutId.unref?.();
|
|
46
50
|
}
|
|
47
51
|
rpcPromiseMap.set(id, { resolve, reject, timeoutId });
|
|
48
52
|
post(serialize({ m: method, a: args, i: id, t: "q" }));
|