vitest 0.21.0 → 0.22.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 +61 -4
- package/dist/browser.d.ts +4 -5
- package/dist/browser.mjs +9 -9
- package/dist/{chunk-api-setup.89eb0e7a.mjs → chunk-api-setup.377c28aa.mjs} +9 -9
- package/dist/chunk-constants.71e8a211.mjs +284 -0
- package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.3aa3eae6.mjs} +3 -2
- package/dist/{chunk-defaults.8390340d.mjs → chunk-integrations-coverage.d205bd87.mjs} +23 -152
- package/dist/{chunk-integrations-globals.a798d352.mjs → chunk-integrations-globals.60af7da3.mjs} +8 -8
- package/dist/{chunk-mock-date.ea3b3121.mjs → chunk-mock-date.304e29b1.mjs} +11 -255
- package/dist/chunk-node-git.9a7e3153.mjs +78 -0
- package/dist/{chunk-runtime-chain.44b4224d.mjs → chunk-runtime-chain.be610650.mjs} +4 -3
- package/dist/{chunk-runtime-error.95e53764.mjs → chunk-runtime-error.1104e45a.mjs} +13 -12
- package/dist/{chunk-runtime-hooks.291644ec.mjs → chunk-runtime-hooks.5d7073db.mjs} +3 -3
- package/dist/{chunk-runtime-mocker.6190d6a3.mjs → chunk-runtime-mocker.49d21aa6.mjs} +19 -5
- package/dist/{chunk-runtime-rpc.fc50dcc0.mjs → chunk-runtime-rpc.57586b73.mjs} +1 -1
- package/dist/{chunk-utils-source-map.d307e4ea.mjs → chunk-utils-source-map.bbf3ad19.mjs} +2 -1
- package/dist/{chunk-vite-node-client.b59ba135.mjs → chunk-vite-node-client.cddda63d.mjs} +49 -21
- package/dist/{chunk-vite-node-debug.dbce2e1f.mjs → chunk-vite-node-debug.536c4c5b.mjs} +3 -3
- package/dist/{chunk-vite-node-externalize.80bed9b3.mjs → chunk-vite-node-externalize.c843f497.mjs} +186 -50
- package/dist/chunk-vite-node-utils.b432150c.mjs +6921 -0
- package/dist/cli-wrapper.mjs +124 -0
- package/dist/cli.mjs +16 -15
- package/dist/config.cjs +3 -0
- package/dist/config.d.ts +6 -3
- package/dist/config.mjs +2 -1
- package/dist/entry.mjs +9 -9
- package/dist/{global-644546f7.d.ts → global-fe52f84b.d.ts} +512 -177
- package/dist/{index-3f764034.d.ts → index-ea17aa0c.d.ts} +4 -52
- package/dist/index.d.ts +5 -6
- package/dist/index.mjs +7 -5
- package/dist/loader.mjs +4 -3
- package/dist/node.d.ts +3 -3
- package/dist/node.mjs +16 -15
- package/dist/suite.mjs +6 -4
- package/dist/{vendor-index.61438b77.mjs → vendor-index.29636037.mjs} +1 -61
- package/dist/{vendor-index.62ce5c33.mjs → vendor-index.2ae8040a.mjs} +0 -0
- package/dist/vendor-index.9d9196cc.mjs +61 -0
- package/dist/{vendor-index.de788b6a.mjs → vendor-index.ae96af6e.mjs} +14 -14
- package/dist/{chunk-node-git.e0dc0a7e.mjs → vendor-index.fbec8a81.mjs} +5 -73
- package/dist/worker.mjs +9 -9
- package/package.json +9 -13
- package/vitest.mjs +1 -1
- package/dist/chunk-constants.9da1ef26.mjs +0 -38
- package/dist/chunk-vite-node-utils.96438e82.mjs +0 -1114
- package/dist/mocker-5e2a8e41.d.ts +0 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { p as picocolors, E as EXIT_CODE_RESTART } from './chunk-constants.71e8a211.mjs';
|
|
3
|
+
import { e as execa } from './vendor-index.fbec8a81.mjs';
|
|
4
|
+
import 'tty';
|
|
5
|
+
import 'path';
|
|
6
|
+
import 'buffer';
|
|
7
|
+
import 'child_process';
|
|
8
|
+
import 'process';
|
|
9
|
+
import './vendor-index.2ae8040a.mjs';
|
|
10
|
+
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
11
|
+
import 'fs';
|
|
12
|
+
import 'stream';
|
|
13
|
+
import 'util';
|
|
14
|
+
import 'os';
|
|
15
|
+
import './vendor-index.29636037.mjs';
|
|
16
|
+
import 'assert';
|
|
17
|
+
import 'events';
|
|
18
|
+
|
|
19
|
+
const ENTRY = new URL("./cli.mjs", import.meta.url);
|
|
20
|
+
const NODE_ARGS = [
|
|
21
|
+
"--inspect",
|
|
22
|
+
"--inspect-brk",
|
|
23
|
+
"--trace-deprecation"
|
|
24
|
+
];
|
|
25
|
+
const SegfaultErrors = [
|
|
26
|
+
{
|
|
27
|
+
trigger: "Check failed: result.second.",
|
|
28
|
+
url: "https://github.com/nodejs/node/issues/43617"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
trigger: "FATAL ERROR: v8::FromJust Maybe value is Nothing.",
|
|
32
|
+
url: "https://github.com/vitest-dev/vitest/issues/1191"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
trigger: "FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.",
|
|
36
|
+
url: "https://github.com/nodejs/node/issues/42407"
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
main();
|
|
40
|
+
async function main() {
|
|
41
|
+
var _a;
|
|
42
|
+
let retries = 0;
|
|
43
|
+
const args = process.argv.slice(2);
|
|
44
|
+
if (process.env.VITEST_SEGFAULT_RETRY) {
|
|
45
|
+
retries = +process.env.VITEST_SEGFAULT_RETRY;
|
|
46
|
+
} else {
|
|
47
|
+
for (let i = 0; i < args.length; i++) {
|
|
48
|
+
if (args[i].startsWith("--segfault-retry=")) {
|
|
49
|
+
retries = +args[i].split("=")[1];
|
|
50
|
+
break;
|
|
51
|
+
} else if (args[i] === "--segfault-retry" && ((_a = args[i + 1]) == null ? void 0 : _a.match(/^\d+$/))) {
|
|
52
|
+
retries = +args[i + 1];
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const nodeArgs = [];
|
|
58
|
+
const vitestArgs = [];
|
|
59
|
+
for (let i = 0; i < args.length; i++) {
|
|
60
|
+
let matched = false;
|
|
61
|
+
for (const nodeArg of NODE_ARGS) {
|
|
62
|
+
if (args[i] === nodeArg || args[i].startsWith(`${nodeArg}=`)) {
|
|
63
|
+
matched = true;
|
|
64
|
+
nodeArgs.push(args[i]);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!matched)
|
|
69
|
+
vitestArgs.push(args[i]);
|
|
70
|
+
}
|
|
71
|
+
retries = Math.max(1, retries || 1);
|
|
72
|
+
for (let i = 1; i <= retries; i++) {
|
|
73
|
+
const result = await start(nodeArgs, vitestArgs);
|
|
74
|
+
if (result === "restart") {
|
|
75
|
+
i -= 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (i === 1 && retries === 1) {
|
|
79
|
+
console.log(picocolors.exports.yellow(`It seems to be an upstream bug of Node.js. To improve the test stability,
|
|
80
|
+
you could pass ${picocolors.exports.bold(picocolors.exports.green("--segfault-retry=3"))} or set env ${picocolors.exports.bold(picocolors.exports.green("VITEST_SEGFAULT_RETRY=3"))} to
|
|
81
|
+
have Vitest auto retries on flaky segfaults.
|
|
82
|
+
`));
|
|
83
|
+
}
|
|
84
|
+
if (i !== retries)
|
|
85
|
+
console.log(`${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.magenta(" Retrying ")))} vitest ${args.join(" ")} ${picocolors.exports.gray(`(${i + 1} of ${retries})`)}`);
|
|
86
|
+
}
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
async function start(preArgs, postArgs) {
|
|
90
|
+
var _a;
|
|
91
|
+
const child = execa("node", [
|
|
92
|
+
...preArgs,
|
|
93
|
+
fileURLToPath(ENTRY),
|
|
94
|
+
...postArgs
|
|
95
|
+
], {
|
|
96
|
+
reject: false,
|
|
97
|
+
stderr: "pipe",
|
|
98
|
+
stdout: "inherit",
|
|
99
|
+
stdin: "inherit",
|
|
100
|
+
env: {
|
|
101
|
+
...process.env,
|
|
102
|
+
VITEST_CLI_WRAPPER: "true"
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
(_a = child.stderr) == null ? void 0 : _a.pipe(process.stderr);
|
|
106
|
+
const { stderr = "" } = await child;
|
|
107
|
+
if (child.exitCode === EXIT_CODE_RESTART)
|
|
108
|
+
return "restart";
|
|
109
|
+
for (const error of SegfaultErrors) {
|
|
110
|
+
if (stderr.includes(error.trigger)) {
|
|
111
|
+
if (process.env.GITHUB_ACTIONS)
|
|
112
|
+
console.log(`::warning:: Segmentfault Error Detected: ${error.trigger}
|
|
113
|
+
Refer to ${error.url}`);
|
|
114
|
+
const RED_BLOCK = picocolors.exports.inverse(picocolors.exports.red(" "));
|
|
115
|
+
console.log(`
|
|
116
|
+
${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.red(" Segmentfault Error Detected ")))}
|
|
117
|
+
${RED_BLOCK} ${picocolors.exports.red(error.trigger)}
|
|
118
|
+
${RED_BLOCK} ${picocolors.exports.red(`Refer to ${error.url}`)}
|
|
119
|
+
`);
|
|
120
|
+
return "error";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
process.exit(child.exitCode);
|
|
124
|
+
}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { p as picocolors } from './chunk-
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
4
|
-
import 'path';
|
|
2
|
+
import { p as picocolors } from './chunk-constants.71e8a211.mjs';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.c843f497.mjs';
|
|
5
4
|
import 'tty';
|
|
6
|
-
import 'local-pkg';
|
|
7
|
-
import './chunk-defaults.8390340d.mjs';
|
|
8
|
-
import 'fs';
|
|
9
|
-
import 'module';
|
|
10
5
|
import 'url';
|
|
6
|
+
import 'path';
|
|
7
|
+
import './chunk-integrations-coverage.d205bd87.mjs';
|
|
8
|
+
import 'local-pkg';
|
|
9
|
+
import './chunk-mock-date.304e29b1.mjs';
|
|
11
10
|
import 'vite';
|
|
12
11
|
import 'process';
|
|
13
|
-
import '
|
|
12
|
+
import 'fs';
|
|
14
13
|
import 'os';
|
|
15
14
|
import 'util';
|
|
16
15
|
import 'stream';
|
|
17
16
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
18
|
-
import './chunk-vite-node-client.
|
|
17
|
+
import './chunk-vite-node-client.cddda63d.mjs';
|
|
18
|
+
import 'module';
|
|
19
19
|
import 'vm';
|
|
20
|
-
import './chunk-vite-node-utils.
|
|
20
|
+
import './chunk-vite-node-utils.b432150c.mjs';
|
|
21
21
|
import 'assert';
|
|
22
22
|
import 'debug';
|
|
23
|
+
import 'perf_hooks';
|
|
23
24
|
import 'worker_threads';
|
|
24
25
|
import 'tinypool';
|
|
25
|
-
import '
|
|
26
|
-
import './chunk-utils-source-map.d307e4ea.mjs';
|
|
26
|
+
import './chunk-utils-source-map.bbf3ad19.mjs';
|
|
27
27
|
import './chunk-utils-timers.b48455ed.mjs';
|
|
28
28
|
import 'crypto';
|
|
29
|
-
import './vendor-index.
|
|
29
|
+
import './vendor-index.9d9196cc.mjs';
|
|
30
|
+
import './vendor-index.29636037.mjs';
|
|
30
31
|
import './chunk-magic-string.efe26975.mjs';
|
|
31
32
|
import 'readline';
|
|
32
|
-
import './vendor-index.
|
|
33
|
+
import './vendor-index.ae96af6e.mjs';
|
|
33
34
|
|
|
34
35
|
function toArr(any) {
|
|
35
36
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -645,7 +646,7 @@ class CAC extends EventEmitter {
|
|
|
645
646
|
const cac = (name = "") => new CAC(name);
|
|
646
647
|
|
|
647
648
|
const cli = cac("vitest");
|
|
648
|
-
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of
|
|
649
|
+
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "enable coverage report").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--browser", "run tests in browser").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--no-color", "Removes colors from the console output").option("--segfault-retry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").help();
|
|
649
650
|
cli.command("run [...filters]").action(run);
|
|
650
651
|
cli.command("related [...filters]").action(runRelated);
|
|
651
652
|
cli.command("watch [...filters]").action(start);
|
package/dist/config.cjs
CHANGED
|
@@ -19,6 +19,7 @@ const defaultCoverageExcludes = [
|
|
|
19
19
|
"**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
|
|
20
20
|
];
|
|
21
21
|
const coverageConfigDefaults = {
|
|
22
|
+
provider: "c8",
|
|
22
23
|
enabled: false,
|
|
23
24
|
clean: true,
|
|
24
25
|
cleanOnRerun: false,
|
|
@@ -85,4 +86,6 @@ function defineConfig(config) {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
exports.configDefaults = configDefaults;
|
|
89
|
+
exports.defaultExclude = defaultExclude;
|
|
90
|
+
exports.defaultInclude = defaultInclude;
|
|
88
91
|
exports.defineConfig = defineConfig;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
|
|
2
2
|
export { ConfigEnv } from 'vite';
|
|
3
|
-
import { U as UserConfig$1,
|
|
3
|
+
import { U as UserConfig$1, a9 as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './global-fe52f84b.js';
|
|
4
|
+
import 'worker_threads';
|
|
4
5
|
import 'fs';
|
|
5
6
|
|
|
7
|
+
declare const defaultInclude: string[];
|
|
8
|
+
declare const defaultExclude: string[];
|
|
6
9
|
declare const config: {
|
|
7
10
|
allowOnly: boolean;
|
|
8
11
|
watch: boolean;
|
|
@@ -30,7 +33,7 @@ declare const config: {
|
|
|
30
33
|
css: {
|
|
31
34
|
include: RegExp[];
|
|
32
35
|
};
|
|
33
|
-
coverage:
|
|
36
|
+
coverage: ResolvedCoverageOptions;
|
|
34
37
|
fakeTimers: FakeTimerInstallOpts;
|
|
35
38
|
maxConcurrency: number;
|
|
36
39
|
dangerouslyIgnoreUnhandledErrors: boolean;
|
|
@@ -45,4 +48,4 @@ declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>
|
|
|
45
48
|
declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
|
|
46
49
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
47
50
|
|
|
48
|
-
export { UserConfig, UserConfigExport, UserConfigFn, configDefaults, defineConfig };
|
|
51
|
+
export { UserConfig, UserConfigExport, UserConfigFn, configDefaults, defaultExclude, defaultInclude, defineConfig };
|
package/dist/config.mjs
CHANGED
|
@@ -15,6 +15,7 @@ const defaultCoverageExcludes = [
|
|
|
15
15
|
"**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
|
|
16
16
|
];
|
|
17
17
|
const coverageConfigDefaults = {
|
|
18
|
+
provider: "c8",
|
|
18
19
|
enabled: false,
|
|
19
20
|
clean: true,
|
|
20
21
|
cleanOnRerun: false,
|
|
@@ -80,4 +81,4 @@ function defineConfig(config) {
|
|
|
80
81
|
return config;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
export { configDefaults, defineConfig };
|
|
84
|
+
export { configDefaults, defaultExclude, defaultInclude, defineConfig };
|
package/dist/entry.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { a as resetModules } from './chunk-mock-date.
|
|
3
|
-
import {
|
|
4
|
-
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.
|
|
2
|
+
import { a as resetModules } from './chunk-mock-date.304e29b1.mjs';
|
|
3
|
+
import { b as envs } from './chunk-integrations-coverage.d205bd87.mjs';
|
|
4
|
+
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.1104e45a.mjs';
|
|
5
5
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
6
6
|
import 'path';
|
|
7
|
+
import './chunk-constants.71e8a211.mjs';
|
|
7
8
|
import 'tty';
|
|
8
|
-
import 'local-pkg';
|
|
9
|
-
import 'module';
|
|
10
9
|
import 'url';
|
|
11
|
-
import '
|
|
12
|
-
import './chunk-runtime-
|
|
10
|
+
import 'local-pkg';
|
|
11
|
+
import './chunk-runtime-hooks.5d7073db.mjs';
|
|
12
|
+
import './chunk-runtime-chain.be610650.mjs';
|
|
13
13
|
import 'util';
|
|
14
14
|
import 'chai';
|
|
15
15
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
16
|
-
import './chunk-runtime-rpc.
|
|
16
|
+
import './chunk-runtime-rpc.57586b73.mjs';
|
|
17
17
|
import './chunk-utils-timers.b48455ed.mjs';
|
|
18
|
-
import './chunk-utils-source-map.
|
|
18
|
+
import './chunk-utils-source-map.bbf3ad19.mjs';
|
|
19
19
|
import './spy.mjs';
|
|
20
20
|
import 'tinyspy';
|
|
21
21
|
|