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
package/dist/node.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { resolveConfig as resolveConfig$1, mergeConfig } from 'vite';
|
|
3
3
|
export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
|
4
|
-
import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.
|
|
5
|
-
export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller,
|
|
6
|
-
export { p as parseCLI } from './chunks/cac.
|
|
7
|
-
import { r as resolveConfig$2 } from './chunks/coverage.
|
|
8
|
-
export { b as BaseSequencer,
|
|
9
|
-
import { slash, deepClone } from '@vitest/utils';
|
|
10
|
-
import {
|
|
4
|
+
import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.W2Q-JQoO.js';
|
|
5
|
+
export { f as ForksPoolWorker, G as GitNotFoundError, F as TestsNotFoundError, T as ThreadsPoolWorker, h as TypecheckPoolWorker, b as VitestPackageInstaller, j as VmForksPoolWorker, k as VmThreadsPoolWorker, o as createDebugger, d as createMethodsRPC, n as createViteLogger, c as createVitest, e as escapeTestName, l as experimental_getRunnerTask, g as getFilePoolName, i as isValidApiRequest, m as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.W2Q-JQoO.js';
|
|
6
|
+
export { p as parseCLI } from './chunks/cac.DrF4Gm0S.js';
|
|
7
|
+
import { r as resolveConfig$2 } from './chunks/coverage.FU3w4IrQ.js';
|
|
8
|
+
export { b as BaseSequencer, a as resolveApiServerConfig } from './chunks/coverage.FU3w4IrQ.js';
|
|
9
|
+
import { slash, deepClone } from '@vitest/utils/helpers';
|
|
10
|
+
import { a as any } from './chunks/index.Dc3xnDvT.js';
|
|
11
11
|
import { resolve } from 'pathe';
|
|
12
12
|
import { c as configFiles } from './chunks/constants.D_Q9UYh-.js';
|
|
13
13
|
export { distDir, rootDir } from './path.js';
|
|
@@ -18,18 +18,19 @@ import 'node:path';
|
|
|
18
18
|
import 'node:os';
|
|
19
19
|
import '@vitest/snapshot/manager';
|
|
20
20
|
import './chunks/index.Bgo3tNWt.js';
|
|
21
|
-
import './chunks/index.
|
|
21
|
+
import './chunks/index.CcRZ6fUh.js';
|
|
22
22
|
import 'node:fs/promises';
|
|
23
|
-
import './chunks/typechecker.DB-fIMaH.js';
|
|
24
23
|
import 'node:perf_hooks';
|
|
25
24
|
import '@vitest/utils/source-map';
|
|
26
|
-
import 'tinyexec';
|
|
27
25
|
import 'tinyrainbow';
|
|
28
26
|
import './chunks/env.D4Lgay0q.js';
|
|
29
27
|
import 'std-env';
|
|
30
28
|
import 'node:util';
|
|
31
29
|
import 'node:console';
|
|
32
30
|
import 'node:stream';
|
|
31
|
+
import '@vitest/utils/display';
|
|
32
|
+
import 'tinyexec';
|
|
33
|
+
import '@vitest/utils/offset';
|
|
33
34
|
import 'node:module';
|
|
34
35
|
import 'events';
|
|
35
36
|
import 'https';
|
|
@@ -46,29 +47,31 @@ import 'node:crypto';
|
|
|
46
47
|
import 'debug';
|
|
47
48
|
import '#module-evaluator';
|
|
48
49
|
import 'vite/module-runner';
|
|
50
|
+
import '@vitest/utils/highlight';
|
|
49
51
|
import 'node:url';
|
|
52
|
+
import 'node:tty';
|
|
53
|
+
import 'node:events';
|
|
54
|
+
import 'node:child_process';
|
|
55
|
+
import 'node:v8';
|
|
56
|
+
import 'node:worker_threads';
|
|
50
57
|
import 'picomatch';
|
|
51
58
|
import 'tinyglobby';
|
|
52
59
|
import 'magic-string';
|
|
53
60
|
import '@vitest/mocker/node';
|
|
54
|
-
import './chunks/defaults.
|
|
55
|
-
import '
|
|
61
|
+
import './chunks/defaults.BOqNVLsY.js';
|
|
62
|
+
import '@vitest/utils/constants';
|
|
63
|
+
import '@vitest/utils/resolver';
|
|
56
64
|
import 'es-module-lexer';
|
|
57
|
-
import './chunks/index.
|
|
65
|
+
import './chunks/index.BdSLhLDZ.js';
|
|
58
66
|
import 'node:assert';
|
|
59
|
-
import '@vitest/utils/
|
|
67
|
+
import '@vitest/utils/serialize';
|
|
60
68
|
import 'node:readline';
|
|
61
69
|
import 'node:process';
|
|
62
|
-
import 'node:v8';
|
|
63
|
-
import 'node:tty';
|
|
64
|
-
import 'node:events';
|
|
65
|
-
import 'tinypool';
|
|
66
|
-
import 'node:worker_threads';
|
|
67
70
|
import 'readline';
|
|
68
71
|
|
|
69
72
|
// this is only exported as a public function and not used inside vitest
|
|
70
73
|
async function resolveConfig(options = {}, viteOverrides = {}) {
|
|
71
|
-
const root = slash(resolve(options.root || process.cwd())), configPath = options.config === false ? false : options.config ? resolve(root, options.config) :
|
|
74
|
+
const root = slash(resolve(options.root || process.cwd())), configPath = options.config === false ? false : options.config ? resolve(root, options.config) : any(configFiles, { cwd: root });
|
|
72
75
|
options.config = configPath;
|
|
73
76
|
const vitest = new Vitest("test", deepClone(options)), config = await resolveConfig$1(mergeConfig({
|
|
74
77
|
configFile: configPath,
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aR as BaseReporter, aS as BenchmarkBuiltinReporters, aE as BenchmarkReporter, aF as BenchmarkReportsMap, aT as BuiltinReporterOptions, aU as BuiltinReporters, aG as DefaultReporter, aH as DotReporter, aI as GithubActionsReporter, aJ as HangingProcessReporter, aL as JUnitReporter, aV as JsonAssertionResult, aK as JsonReporter, aW as JsonTestResult, aX as JsonTestResults, aB as ReportedHookContext, aC as Reporter, aM as ReportersMap, aN as TapFlatReporter, aO as TapReporter, aD as TestRunEndReason, aP as VerboseBenchmarkReporter, aQ as VerboseReporter } from './chunks/reporters.d.BMKt7f6I.js';
|
|
2
2
|
import '@vitest/runner';
|
|
3
3
|
import '@vitest/utils';
|
|
4
|
-
import './chunks/
|
|
5
|
-
import 'node:stream';
|
|
6
|
-
import 'vite';
|
|
7
|
-
import '@vitest/mocker';
|
|
8
|
-
import '@vitest/utils/source-map';
|
|
9
|
-
import './chunks/browser.d.DtfyY9yS.js';
|
|
10
|
-
import './chunks/worker.d.B2r4Ln6p.js';
|
|
4
|
+
import './chunks/worker.d.BFk-vvBU.js';
|
|
11
5
|
import 'vite/module-runner';
|
|
12
|
-
import './chunks/config.d.
|
|
6
|
+
import './chunks/config.d.u2CUDWwS.js';
|
|
13
7
|
import '@vitest/pretty-format';
|
|
14
8
|
import '@vitest/snapshot';
|
|
15
9
|
import '@vitest/utils/diff';
|
|
10
|
+
import './chunks/environment.d.CrsxCzP1.js';
|
|
11
|
+
import 'node:stream';
|
|
12
|
+
import 'vite';
|
|
13
|
+
import '@vitest/mocker';
|
|
14
|
+
import '@vitest/utils/source-map';
|
|
15
|
+
import 'vitest/browser';
|
|
16
|
+
import './chunks/browser.d.B9iJzZyn.js';
|
|
16
17
|
import '@vitest/expect';
|
|
17
18
|
import 'vitest/optional-types.js';
|
|
18
19
|
import './chunks/benchmark.d.DAaHLpsq.js';
|
package/dist/reporters.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.
|
|
2
|
-
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.
|
|
1
|
+
export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.CcRZ6fUh.js';
|
|
2
|
+
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.BdSLhLDZ.js';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:fs/promises';
|
|
5
5
|
import 'pathe';
|
|
6
|
-
import './chunks/typechecker.DB-fIMaH.js';
|
|
7
|
-
import 'node:os';
|
|
8
6
|
import 'node:perf_hooks';
|
|
9
|
-
import '@vitest/utils/source-map';
|
|
10
|
-
import 'tinyexec';
|
|
11
|
-
import './path.js';
|
|
12
|
-
import 'node:path';
|
|
13
|
-
import 'node:url';
|
|
14
7
|
import '@vitest/runner/utils';
|
|
15
|
-
import '@vitest/utils';
|
|
16
|
-
import '
|
|
8
|
+
import '@vitest/utils/helpers';
|
|
9
|
+
import '@vitest/utils/source-map';
|
|
17
10
|
import 'tinyrainbow';
|
|
18
11
|
import './chunks/env.D4Lgay0q.js';
|
|
19
12
|
import 'std-env';
|
|
20
13
|
import 'node:util';
|
|
21
14
|
import 'node:console';
|
|
22
15
|
import 'node:stream';
|
|
16
|
+
import '@vitest/utils/display';
|
|
17
|
+
import 'node:os';
|
|
18
|
+
import 'tinyexec';
|
|
19
|
+
import './path.js';
|
|
20
|
+
import 'node:path';
|
|
21
|
+
import 'node:url';
|
|
22
|
+
import 'vite';
|
|
23
|
+
import '@vitest/utils/offset';
|
|
23
24
|
import 'node:module';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as tinybench from 'tinybench';
|
|
2
2
|
import { VitestRunner, VitestRunnerImportSource, Suite, File, Task, CancelReason, Test, TestContext, ImportDuration } from '@vitest/runner';
|
|
3
3
|
export { VitestRunner } from '@vitest/runner';
|
|
4
|
-
import {
|
|
4
|
+
import { S as SerializedConfig } from './chunks/config.d.u2CUDWwS.js';
|
|
5
5
|
import '@vitest/pretty-format';
|
|
6
6
|
import '@vitest/snapshot';
|
|
7
7
|
import '@vitest/utils/diff';
|
package/dist/runners.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export { N as NodeBenchmarkRunner, V as VitestTestRunner } from './chunks/test.
|
|
1
|
+
export { N as NodeBenchmarkRunner, V as VitestTestRunner } from './chunks/test.C3RPt8JR.js';
|
|
2
2
|
import '@vitest/runner';
|
|
3
|
-
import '@vitest/utils';
|
|
4
|
-
import '
|
|
3
|
+
import '@vitest/utils/helpers';
|
|
4
|
+
import '@vitest/utils/timers';
|
|
5
|
+
import './chunks/benchmark.DHKMYAts.js';
|
|
5
6
|
import '@vitest/runner/utils';
|
|
6
|
-
import './chunks/utils.
|
|
7
|
+
import './chunks/utils.CG9h5ccR.js';
|
|
7
8
|
import '@vitest/expect';
|
|
8
9
|
import '@vitest/utils/error';
|
|
9
10
|
import 'pathe';
|
|
10
|
-
import './chunks/vi.
|
|
11
|
-
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
11
|
+
import './chunks/vi.BZvkKVkM.js';
|
|
12
12
|
import '@vitest/snapshot';
|
|
13
13
|
import '@vitest/spy';
|
|
14
|
+
import '@vitest/utils/offset';
|
|
14
15
|
import '@vitest/utils/source-map';
|
|
16
|
+
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
15
17
|
import './chunks/date.-jtEtIeV.js';
|
|
16
|
-
import './chunks/rpc.
|
|
18
|
+
import './chunks/rpc.cD77ENhU.js';
|
|
17
19
|
import './chunks/index.Bgo3tNWt.js';
|
package/dist/snapshot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.
|
|
1
|
+
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.BwAWWjHZ.js';
|
|
2
2
|
import '@vitest/snapshot/environment';
|
|
3
|
-
import './chunks/utils.
|
|
4
|
-
import '@vitest/utils';
|
|
3
|
+
import './chunks/utils.CG9h5ccR.js';
|
|
4
|
+
import '@vitest/utils/timers';
|
package/dist/suite.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.
|
|
1
|
+
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.DHKMYAts.js';
|
|
2
2
|
export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
|
3
3
|
export { createChainable } from '@vitest/runner/utils';
|
|
4
|
-
import '@vitest/utils';
|
|
5
|
-
import './chunks/utils.
|
|
4
|
+
import '@vitest/utils/helpers';
|
|
5
|
+
import './chunks/utils.CG9h5ccR.js';
|
|
6
|
+
import '@vitest/utils/timers';
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { W as WorkerGlobalState, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.BFk-vvBU.js';
|
|
2
|
+
import { Awaitable } from '@vitest/utils';
|
|
3
|
+
import '@vitest/runner';
|
|
4
|
+
import 'vite/module-runner';
|
|
5
|
+
import './chunks/config.d.u2CUDWwS.js';
|
|
6
|
+
import '@vitest/pretty-format';
|
|
7
|
+
import '@vitest/snapshot';
|
|
8
|
+
import '@vitest/utils/diff';
|
|
9
|
+
import './chunks/environment.d.CrsxCzP1.js';
|
|
10
|
+
|
|
11
|
+
/** @experimental */
|
|
12
|
+
declare function runBaseTests(method: "run" | "collect", state: WorkerGlobalState): Promise<void>;
|
|
13
|
+
|
|
14
|
+
type WorkerRpcOptions = Pick<BirpcOptions<RuntimeRPC>, "on" | "off" | "post" | "serialize" | "deserialize">;
|
|
15
|
+
interface VitestWorker extends WorkerRpcOptions {
|
|
16
|
+
runTests: (state: WorkerGlobalState) => Awaitable<unknown>;
|
|
17
|
+
collectTests: (state: WorkerGlobalState) => Awaitable<unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Options extends VitestWorker {
|
|
21
|
+
teardown?: () => void;
|
|
22
|
+
}
|
|
23
|
+
/** @experimental */
|
|
24
|
+
declare function init(worker: Options): void;
|
|
25
|
+
|
|
26
|
+
export { init, runBaseTests };
|
package/dist/worker.js
CHANGED
|
@@ -1,166 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import 'node:
|
|
15
|
-
import '@vitest/utils';
|
|
1
|
+
export { r as runBaseTests } from './chunks/base.BYPMk0VN.js';
|
|
2
|
+
export { i as init } from './chunks/init.94FWN9pW.js';
|
|
3
|
+
import 'node:vm';
|
|
4
|
+
import '@vitest/spy';
|
|
5
|
+
import './chunks/evaluatedModules.Dg1zASAC.js';
|
|
6
|
+
import 'pathe';
|
|
7
|
+
import 'vite/module-runner';
|
|
8
|
+
import './chunks/startModuleRunner.iF1E9Bt4.js';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:module';
|
|
11
|
+
import '@vitest/utils/helpers';
|
|
12
|
+
import 'node:url';
|
|
13
|
+
import './path.js';
|
|
14
|
+
import 'node:path';
|
|
15
|
+
import '@vitest/utils/serialize';
|
|
16
|
+
import './module-evaluator.js';
|
|
17
|
+
import '@vitest/mocker';
|
|
18
|
+
import 'node:perf_hooks';
|
|
19
|
+
import '@vitest/runner';
|
|
20
|
+
import './chunks/resolveSnapshotEnvironment.DJJKMKxb.js';
|
|
21
|
+
import '@vitest/expect';
|
|
22
|
+
import './chunks/setup-common.DR1sucx6.js';
|
|
23
|
+
import './chunks/coverage.D_JHT54q.js';
|
|
24
|
+
import '@vitest/snapshot';
|
|
25
|
+
import '@vitest/utils/timers';
|
|
26
|
+
import './chunks/utils.CG9h5ccR.js';
|
|
27
|
+
import './chunks/rpc.cD77ENhU.js';
|
|
16
28
|
import './chunks/index.Bgo3tNWt.js';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
code,
|
|
36
|
-
...result
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (isWindows && "externalize" in result)
|
|
40
|
-
// TODO: vitest returns paths for external modules, but Vite returns file://
|
|
41
|
-
// https://github.com/vitejs/vite/pull/20449
|
|
42
|
-
result.externalize = isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id) ? result.externalize : pathToFileURL(result.externalize).toString();
|
|
43
|
-
return result;
|
|
44
|
-
},
|
|
45
|
-
async resolveId(id, importer) {
|
|
46
|
-
return rpc.resolve(id, importer, "__vitest__");
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
});
|
|
50
|
-
_loaders.set(root, moduleRunner), await moduleRunner.import("/@vite/env");
|
|
51
|
-
}
|
|
52
|
-
return _loaders.get(root);
|
|
53
|
-
}
|
|
54
|
-
async function loadEnvironment(ctx, rpc) {
|
|
55
|
-
const name = ctx.environment.name;
|
|
56
|
-
if (isBuiltinEnvironment(name)) return { environment: environments[name] };
|
|
57
|
-
const root = ctx.config.root, loader = await createEnvironmentLoader(root, rpc), packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolve(`vitest-environment-${name}`, void 0, "__vitest__"))?.id ?? resolve(root, name), pkg = await loader.import(packageId);
|
|
58
|
-
if (!pkg || !pkg.default || typeof pkg.default !== "object") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`);
|
|
59
|
-
const environment = pkg.default;
|
|
60
|
-
if (environment.transformMode != null && environment.transformMode !== "web" && environment.transformMode !== "ssr") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web", received "${environment.transformMode}".`);
|
|
61
|
-
if (environment.transformMode)
|
|
62
|
-
// keep for backwards compat
|
|
63
|
-
console.warn(`The Vitest environment ${environment.name} defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.`), environment.viteEnvironment ??= environment.transformMode === "ssr" ? "ssr" : "client";
|
|
64
|
-
return {
|
|
65
|
-
environment,
|
|
66
|
-
loader
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
71
|
-
function addCleanupListener(listener) {
|
|
72
|
-
listeners.add(listener);
|
|
73
|
-
}
|
|
74
|
-
async function cleanup() {
|
|
75
|
-
const promises = [...listeners].map((l) => l());
|
|
76
|
-
await Promise.all(promises);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (isChildProcess()) {
|
|
80
|
-
const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
|
|
81
|
-
if (isProfiling)
|
|
82
|
-
// Work-around for nodejs/node#55094
|
|
83
|
-
process.on("SIGTERM", () => {
|
|
84
|
-
process.exit();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
const resolvingModules = /* @__PURE__ */ new Set();
|
|
88
|
-
// this is what every pool executes when running tests
|
|
89
|
-
async function execute(method, ctx) {
|
|
90
|
-
disposeInternalListeners();
|
|
91
|
-
const prepareStart = performance.now(), cleanups = [setupInspect(ctx)];
|
|
92
|
-
process.env.VITEST_WORKER_ID = String(ctx.workerId), process.env.VITEST_POOL_ID = String(workerId);
|
|
93
|
-
let environmentLoader;
|
|
94
|
-
try {
|
|
95
|
-
// worker is a filepath or URL to a file that exposes a default export with "getRpcOptions" and "runTests" methods
|
|
96
|
-
if (ctx.worker[0] === ".") throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
|
|
97
|
-
const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString(), testRunnerModule = await import(file);
|
|
98
|
-
if (!testRunnerModule.default || typeof testRunnerModule.default !== "object") throw new TypeError(`Test worker object should be exposed as a default export. Received "${typeof testRunnerModule.default}"`);
|
|
99
|
-
const worker = testRunnerModule.default;
|
|
100
|
-
if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
|
|
101
|
-
// RPC is used to communicate between worker (be it a thread worker or child process or a custom implementation) and the main thread
|
|
102
|
-
const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
|
|
103
|
-
// do not close the RPC channel so that we can get the error messages sent to the main thread
|
|
104
|
-
cleanups.push(async () => {
|
|
105
|
-
await Promise.all(rpc.$rejectPendingCalls(({ method, reject }) => {
|
|
106
|
-
reject(/* @__PURE__ */ new Error(`[vitest-worker]: Closing rpc while "${method}" was pending`));
|
|
107
|
-
}));
|
|
108
|
-
});
|
|
109
|
-
const beforeEnvironmentTime = performance.now(), { environment, loader } = await loadEnvironment(ctx, rpc);
|
|
110
|
-
environmentLoader = loader;
|
|
111
|
-
const state = {
|
|
112
|
-
ctx,
|
|
113
|
-
evaluatedModules: new EvaluatedModules(),
|
|
114
|
-
resolvingModules,
|
|
115
|
-
moduleExecutionInfo: /* @__PURE__ */ new Map(),
|
|
116
|
-
config: ctx.config,
|
|
117
|
-
onCancel,
|
|
118
|
-
environment,
|
|
119
|
-
durations: {
|
|
120
|
-
environment: beforeEnvironmentTime,
|
|
121
|
-
prepare: prepareStart
|
|
122
|
-
},
|
|
123
|
-
rpc,
|
|
124
|
-
onCleanup: (listener) => addCleanupListener(listener),
|
|
125
|
-
providedContext: ctx.providedContext,
|
|
126
|
-
onFilterStackTrace(stack) {
|
|
127
|
-
return createStackString(parseStacktrace(stack));
|
|
128
|
-
},
|
|
129
|
-
metaEnv: createImportMetaEnvProxy()
|
|
130
|
-
}, methodName = method === "collect" ? "collectTests" : "runTests";
|
|
131
|
-
if (!worker[methodName] || typeof worker[methodName] !== "function") throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
|
|
132
|
-
await worker[methodName](state);
|
|
133
|
-
} finally {
|
|
134
|
-
await Promise.all(cleanups.map((fn) => fn())), await rpcDone().catch(() => {}), environmentLoader?.close();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function run(ctx) {
|
|
138
|
-
return execute("run", ctx);
|
|
139
|
-
}
|
|
140
|
-
function collect(ctx) {
|
|
141
|
-
return execute("collect", ctx);
|
|
142
|
-
}
|
|
143
|
-
async function teardown() {
|
|
144
|
-
return cleanup();
|
|
145
|
-
}
|
|
146
|
-
function createImportMetaEnvProxy() {
|
|
147
|
-
// packages/vitest/src/node/plugins/index.ts:146
|
|
148
|
-
const booleanKeys = [
|
|
149
|
-
"DEV",
|
|
150
|
-
"PROD",
|
|
151
|
-
"SSR"
|
|
152
|
-
];
|
|
153
|
-
return new Proxy(process.env, {
|
|
154
|
-
get(_, key) {
|
|
155
|
-
return typeof key === "string" ? booleanKeys.includes(key) ? !!process.env[key] : process.env[key] : void 0;
|
|
156
|
-
},
|
|
157
|
-
set(_, key, value) {
|
|
158
|
-
if (typeof key !== "string") return true;
|
|
159
|
-
if (booleanKeys.includes(key)) process.env[key] = value ? "1" : "";
|
|
160
|
-
else process.env[key] = value;
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export { collect, run, teardown };
|
|
29
|
+
import './chunks/test.C3RPt8JR.js';
|
|
30
|
+
import './chunks/benchmark.DHKMYAts.js';
|
|
31
|
+
import '@vitest/runner/utils';
|
|
32
|
+
import '@vitest/utils/error';
|
|
33
|
+
import './chunks/vi.BZvkKVkM.js';
|
|
34
|
+
import '@vitest/utils/offset';
|
|
35
|
+
import '@vitest/utils/source-map';
|
|
36
|
+
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
37
|
+
import './chunks/date.-jtEtIeV.js';
|
|
38
|
+
import './chunks/inspector.DLZxSeU3.js';
|
|
39
|
+
import 'node:timers';
|
|
40
|
+
import 'node:timers/promises';
|
|
41
|
+
import 'node:util';
|
|
42
|
+
import '@vitest/utils/constants';
|
|
43
|
+
import './chunks/index.RwjEGCQ0.js';
|
|
44
|
+
import 'expect-type';
|
|
45
|
+
import './chunks/index.CbWINfS7.js';
|
|
46
|
+
import 'node:console';
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,67 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.C2YI6McM.js';
|
|
1
|
+
import { r as runBaseTests } from '../chunks/base.BYPMk0VN.js';
|
|
2
|
+
import { w as workerInit } from '../chunks/init-forks.WglB-sfY.js';
|
|
4
3
|
import 'node:vm';
|
|
5
4
|
import '@vitest/spy';
|
|
5
|
+
import '../chunks/evaluatedModules.Dg1zASAC.js';
|
|
6
|
+
import 'pathe';
|
|
6
7
|
import 'vite/module-runner';
|
|
7
|
-
import '../chunks/startModuleRunner.
|
|
8
|
+
import '../chunks/startModuleRunner.iF1E9Bt4.js';
|
|
8
9
|
import 'node:fs';
|
|
9
10
|
import 'node:module';
|
|
10
|
-
import '@vitest/utils';
|
|
11
|
+
import '@vitest/utils/helpers';
|
|
11
12
|
import 'node:url';
|
|
12
|
-
import 'pathe';
|
|
13
13
|
import '../path.js';
|
|
14
14
|
import 'node:path';
|
|
15
|
-
import '@vitest/utils/
|
|
15
|
+
import '@vitest/utils/serialize';
|
|
16
16
|
import '../module-evaluator.js';
|
|
17
17
|
import '@vitest/mocker';
|
|
18
|
-
import '../chunks/moduleTransport.I-bgQy0S.js';
|
|
19
18
|
import 'node:perf_hooks';
|
|
20
19
|
import '@vitest/runner';
|
|
21
|
-
import '../chunks/resolveSnapshotEnvironment.
|
|
20
|
+
import '../chunks/resolveSnapshotEnvironment.DJJKMKxb.js';
|
|
22
21
|
import '@vitest/expect';
|
|
23
|
-
import '../chunks/setup-common.
|
|
22
|
+
import '../chunks/setup-common.DR1sucx6.js';
|
|
24
23
|
import '../chunks/coverage.D_JHT54q.js';
|
|
25
24
|
import '@vitest/snapshot';
|
|
26
|
-
import '
|
|
27
|
-
import '../chunks/
|
|
25
|
+
import '@vitest/utils/timers';
|
|
26
|
+
import '../chunks/utils.CG9h5ccR.js';
|
|
27
|
+
import '../chunks/rpc.cD77ENhU.js';
|
|
28
28
|
import '../chunks/index.Bgo3tNWt.js';
|
|
29
|
-
import '../chunks/test.
|
|
30
|
-
import '../chunks/benchmark.
|
|
29
|
+
import '../chunks/test.C3RPt8JR.js';
|
|
30
|
+
import '../chunks/benchmark.DHKMYAts.js';
|
|
31
31
|
import '@vitest/runner/utils';
|
|
32
|
-
import '
|
|
33
|
-
import '../chunks/
|
|
32
|
+
import '@vitest/utils/error';
|
|
33
|
+
import '../chunks/vi.BZvkKVkM.js';
|
|
34
|
+
import '@vitest/utils/offset';
|
|
34
35
|
import '@vitest/utils/source-map';
|
|
36
|
+
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
35
37
|
import '../chunks/date.-jtEtIeV.js';
|
|
36
|
-
import '../chunks/inspector.
|
|
38
|
+
import '../chunks/inspector.DLZxSeU3.js';
|
|
37
39
|
import 'node:timers';
|
|
38
40
|
import 'node:timers/promises';
|
|
39
41
|
import 'node:util';
|
|
40
|
-
import '
|
|
42
|
+
import '@vitest/utils/constants';
|
|
43
|
+
import '../chunks/index.RwjEGCQ0.js';
|
|
41
44
|
import 'expect-type';
|
|
45
|
+
import 'node:v8';
|
|
46
|
+
import '../chunks/init.94FWN9pW.js';
|
|
47
|
+
import '../chunks/index.CbWINfS7.js';
|
|
48
|
+
import 'node:console';
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
getRpcOptions() {
|
|
45
|
-
return createForksRpcOptions(v8);
|
|
46
|
-
}
|
|
47
|
-
async executeTests(method, state) {
|
|
48
|
-
// TODO: don't rely on reassigning process.exit
|
|
49
|
-
// https://github.com/vitest-dev/vitest/pull/4441#discussion_r1443771486
|
|
50
|
-
const exit = process.exit;
|
|
51
|
-
state.ctx.config = unwrapSerializableConfig(state.ctx.config);
|
|
52
|
-
try {
|
|
53
|
-
await runBaseTests(method, state);
|
|
54
|
-
} finally {
|
|
55
|
-
process.exit = exit;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
runTests(state) {
|
|
59
|
-
return this.executeTests("run", state);
|
|
60
|
-
}
|
|
61
|
-
collectTests(state) {
|
|
62
|
-
return this.executeTests("collect", state);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const worker = new ForksBaseWorker();
|
|
66
|
-
|
|
67
|
-
export { worker as default };
|
|
50
|
+
workerInit({ runTests: runBaseTests });
|
|
@@ -4,29 +4,33 @@ import timers from 'node:timers';
|
|
|
4
4
|
import timersPromises from 'node:timers/promises';
|
|
5
5
|
import util from 'node:util';
|
|
6
6
|
import { startTests, collectTests } from '@vitest/runner';
|
|
7
|
-
import { KNOWN_ASSET_TYPES } from '@vitest/utils';
|
|
8
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/resolveSnapshotEnvironment.
|
|
9
|
-
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.
|
|
10
|
-
import { i as index } from '../chunks/index.
|
|
11
|
-
import { c as closeInspector } from '../chunks/inspector.
|
|
12
|
-
import { g as getWorkerState } from '../chunks/utils.
|
|
13
|
-
import { g as globalExpect } from '../chunks/vi.
|
|
7
|
+
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
8
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/resolveSnapshotEnvironment.DJJKMKxb.js';
|
|
9
|
+
import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.DR1sucx6.js';
|
|
10
|
+
import { i as index } from '../chunks/index.RwjEGCQ0.js';
|
|
11
|
+
import { c as closeInspector } from '../chunks/inspector.DLZxSeU3.js';
|
|
12
|
+
import { g as getWorkerState } from '../chunks/utils.CG9h5ccR.js';
|
|
13
|
+
import { g as globalExpect } from '../chunks/vi.BZvkKVkM.js';
|
|
14
14
|
import '@vitest/expect';
|
|
15
|
-
import '../chunks/rpc.
|
|
15
|
+
import '../chunks/rpc.cD77ENhU.js';
|
|
16
|
+
import '@vitest/utils/timers';
|
|
16
17
|
import '../chunks/index.Bgo3tNWt.js';
|
|
17
|
-
import '../chunks/test.
|
|
18
|
-
import '
|
|
18
|
+
import '../chunks/test.C3RPt8JR.js';
|
|
19
|
+
import '@vitest/utils/helpers';
|
|
20
|
+
import '../chunks/benchmark.DHKMYAts.js';
|
|
19
21
|
import '@vitest/runner/utils';
|
|
20
22
|
import '@vitest/utils/error';
|
|
21
23
|
import 'pathe';
|
|
22
24
|
import '../chunks/coverage.D_JHT54q.js';
|
|
23
25
|
import '@vitest/snapshot';
|
|
24
|
-
import '
|
|
26
|
+
import '../chunks/evaluatedModules.Dg1zASAC.js';
|
|
25
27
|
import 'vite/module-runner';
|
|
28
|
+
import 'expect-type';
|
|
26
29
|
import 'node:url';
|
|
27
|
-
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
28
30
|
import '@vitest/spy';
|
|
31
|
+
import '@vitest/utils/offset';
|
|
29
32
|
import '@vitest/utils/source-map';
|
|
33
|
+
import '../chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
30
34
|
import '../chunks/date.-jtEtIeV.js';
|
|
31
35
|
|
|
32
36
|
async function run(method, files, config, moduleRunner) {
|