vitest 0.22.0 → 0.23.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 +29 -29
- package/dist/browser.d.ts +5 -4
- package/dist/browser.mjs +12 -9
- package/dist/{chunk-api-setup.ecd02c18.mjs → chunk-api-setup.9e83ca0a.mjs} +92 -90
- package/dist/chunk-constants.6196597b.mjs +284 -0
- package/dist/{chunk-integrations-coverage.d205bd87.mjs → chunk-env-node.ceb43f1c.mjs} +31 -179
- package/dist/{chunk-install-pkg.3aa3eae6.mjs → chunk-install-pkg.e081fc1b.mjs} +3 -3
- package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
- package/dist/chunk-integrations-globals.b1aa52c3.mjs +25 -0
- package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
- package/dist/{chunk-mock-date.debe9954.mjs → chunk-mock-date.f63a5ff2.mjs} +31 -193
- package/dist/{chunk-node-git.71b74da4.mjs → chunk-node-git.6f289b0a.mjs} +20 -16
- package/dist/{chunk-runtime-chain.6e363ba2.mjs → chunk-runtime-chain.8bfc559b.mjs} +507 -173
- package/dist/{chunk-runtime-error.975bd80a.mjs → chunk-runtime-error.252dd130.mjs} +206 -75
- package/dist/{chunk-runtime-hooks.4789e99d.mjs → chunk-runtime-hooks.c6b06bd8.mjs} +18 -12
- package/dist/{chunk-runtime-mocker.c91d29ce.mjs → chunk-runtime-mocker.d9690273.mjs} +19 -12
- package/dist/{chunk-runtime-rpc.29488183.mjs → chunk-runtime-rpc.48bd94e3.mjs} +1 -2
- package/dist/{chunk-utils-source-map.2a082ffd.mjs → chunk-utils-source-map.a1647f5f.mjs} +11 -5
- package/dist/{chunk-vite-node-client.d1ead698.mjs → chunk-vite-node-client.998e04d0.mjs} +92 -31
- package/dist/{chunk-vite-node-debug.ff1d2a9f.mjs → chunk-vite-node-debug.2d8a1dc3.mjs} +3 -4
- package/dist/{chunk-vite-node-externalize.3a38c8af.mjs → chunk-vite-node-externalize.3035bd5b.mjs} +515 -211
- package/dist/{chunk-vite-node-utils.d8e5ff7b.mjs → chunk-vite-node-utils.8a9b3014.mjs} +39 -41
- package/dist/cli-wrapper.mjs +54 -33
- package/dist/cli.mjs +31 -20
- package/dist/config.cjs +2 -2
- package/dist/config.d.ts +4 -3
- package/dist/config.mjs +2 -2
- package/dist/entry.mjs +20 -14
- package/dist/environments.d.ts +23 -0
- package/dist/environments.mjs +3 -0
- package/dist/{global-74489cc9.d.ts → global-ea084c9f.d.ts} +154 -24
- package/dist/{index-9eded9ec.d.ts → index-5f09f4d0.d.ts} +3 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +7 -7
- package/dist/loader.mjs +5 -6
- package/dist/node.d.ts +5 -4
- package/dist/node.mjs +17 -16
- package/dist/suite.mjs +6 -6
- package/dist/vendor-index.0557b03a.mjs +147 -0
- package/dist/{vendor-index.9d9196cc.mjs → vendor-index.13e3bda3.mjs} +0 -0
- package/dist/{vendor-index.fbec8a81.mjs → vendor-index.4aeeb598.mjs} +2 -2
- package/dist/{vendor-index.2ae8040a.mjs → vendor-index.62ce5c33.mjs} +0 -0
- package/dist/{vendor-index.29636037.mjs → vendor-index.731a22f2.mjs} +0 -0
- package/dist/worker.mjs +20 -19
- package/package.json +18 -11
- package/dist/chunk-constants.d3f8437b.mjs +0 -38
- package/dist/chunk-integrations-globals.e81d2091.mjs +0 -27
- package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
- package/dist/vendor-picocolors.807856aa.mjs +0 -64
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
|
|
2
|
+
import { a as resolve$1, r as relative } from './chunk-constants.6196597b.mjs';
|
|
1
3
|
import { builtinModules } from 'module';
|
|
2
4
|
import fs, { promises, statSync, existsSync, realpathSync, Stats } from 'fs';
|
|
3
|
-
import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
|
|
4
5
|
import path from 'path';
|
|
5
6
|
import assert from 'assert';
|
|
6
7
|
import { format, inspect } from 'util';
|
|
7
|
-
import { x as resolve$1 } from './chunk-mock-date.debe9954.mjs';
|
|
8
8
|
|
|
9
9
|
// This file was generated. Do not modify manually!
|
|
10
10
|
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
|
@@ -5587,50 +5587,22 @@ function joinURL(base, ...input) {
|
|
|
5587
5587
|
return url;
|
|
5588
5588
|
}
|
|
5589
5589
|
|
|
5590
|
-
function normalizeWindowsPath$1(input = "") {
|
|
5591
|
-
if (!input || !input.includes("\\")) {
|
|
5592
|
-
return input;
|
|
5593
|
-
}
|
|
5594
|
-
return input.replace(/\\/g, "/");
|
|
5595
|
-
}
|
|
5596
|
-
const _IS_ABSOLUTE_RE$1 = /^[\\/](?![\\/])|^[\\/]{2}(?!\.)|^[a-zA-Z]:[\\/]/;
|
|
5597
|
-
const isAbsolute$1 = function(p) {
|
|
5598
|
-
return _IS_ABSOLUTE_RE$1.test(p);
|
|
5599
|
-
};
|
|
5600
|
-
const _EXTNAME_RE = /(?<!^)\.[^/.]+$/;
|
|
5601
|
-
const extname = function(p) {
|
|
5602
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath$1(p));
|
|
5603
|
-
return match && match[0] || "";
|
|
5604
|
-
};
|
|
5605
|
-
|
|
5606
|
-
/*---------------------------------------------------------------------------------------------
|
|
5607
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5608
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5609
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5610
|
-
var ParseOptions;
|
|
5611
|
-
(function (ParseOptions) {
|
|
5612
|
-
ParseOptions.DEFAULT = {
|
|
5613
|
-
allowTrailingComma: false
|
|
5614
|
-
};
|
|
5615
|
-
})(ParseOptions || (ParseOptions = {}));
|
|
5616
|
-
|
|
5617
5590
|
function normalizeWindowsPath(input = "") {
|
|
5618
|
-
if (!input.includes("\\")) {
|
|
5591
|
+
if (!input || !input.includes("\\")) {
|
|
5619
5592
|
return input;
|
|
5620
5593
|
}
|
|
5621
5594
|
return input.replace(/\\/g, "/");
|
|
5622
5595
|
}
|
|
5623
5596
|
|
|
5624
|
-
const _UNC_REGEX = /^[
|
|
5625
|
-
const
|
|
5626
|
-
const
|
|
5597
|
+
const _UNC_REGEX = /^[\\/]{2}/;
|
|
5598
|
+
const _IS_ABSOLUTE_RE = /^[\\/](?![\\/])|^[\\/]{2}(?!\.)|^[a-zA-Z]:[\\/]/;
|
|
5599
|
+
const _DRIVE_LETTER_RE = /^[a-zA-Z]:$/;
|
|
5627
5600
|
const normalize = function(path) {
|
|
5628
5601
|
if (path.length === 0) {
|
|
5629
5602
|
return ".";
|
|
5630
5603
|
}
|
|
5631
5604
|
path = normalizeWindowsPath(path);
|
|
5632
5605
|
const isUNCPath = path.match(_UNC_REGEX);
|
|
5633
|
-
const hasUNCDrive = isUNCPath && path.match(_UNC_DRIVE_REGEX);
|
|
5634
5606
|
const isPathAbsolute = isAbsolute(path);
|
|
5635
5607
|
const trailingSeparator = path[path.length - 1] === "/";
|
|
5636
5608
|
path = normalizeString(path, !isPathAbsolute);
|
|
@@ -5643,8 +5615,11 @@ const normalize = function(path) {
|
|
|
5643
5615
|
if (trailingSeparator) {
|
|
5644
5616
|
path += "/";
|
|
5645
5617
|
}
|
|
5618
|
+
if (_DRIVE_LETTER_RE.test(path)) {
|
|
5619
|
+
path += "/";
|
|
5620
|
+
}
|
|
5646
5621
|
if (isUNCPath) {
|
|
5647
|
-
if (
|
|
5622
|
+
if (!isPathAbsolute) {
|
|
5648
5623
|
return `//./${path}`;
|
|
5649
5624
|
}
|
|
5650
5625
|
return `//${path}`;
|
|
@@ -5658,7 +5633,7 @@ const join = function(...args) {
|
|
|
5658
5633
|
let joined;
|
|
5659
5634
|
for (let i = 0; i < args.length; ++i) {
|
|
5660
5635
|
const arg = args[i];
|
|
5661
|
-
if (arg.length > 0) {
|
|
5636
|
+
if (arg && arg.length > 0) {
|
|
5662
5637
|
if (joined === void 0) {
|
|
5663
5638
|
joined = arg;
|
|
5664
5639
|
} else {
|
|
@@ -5676,8 +5651,8 @@ const resolve = function(...args) {
|
|
|
5676
5651
|
let resolvedPath = "";
|
|
5677
5652
|
let resolvedAbsolute = false;
|
|
5678
5653
|
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
5679
|
-
const path = i >= 0 ? args[i] : process.cwd();
|
|
5680
|
-
if (path.length === 0) {
|
|
5654
|
+
const path = i >= 0 ? args[i] : process.cwd().replace(/\\/g, "/");
|
|
5655
|
+
if (!path || path.length === 0) {
|
|
5681
5656
|
continue;
|
|
5682
5657
|
}
|
|
5683
5658
|
resolvedPath = `${path}/${resolvedPath}`;
|
|
@@ -5751,6 +5726,11 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
5751
5726
|
const isAbsolute = function(p) {
|
|
5752
5727
|
return _IS_ABSOLUTE_RE.test(p);
|
|
5753
5728
|
};
|
|
5729
|
+
const _EXTNAME_RE = /.(\.[^/.]+)$/;
|
|
5730
|
+
const extname = function(p) {
|
|
5731
|
+
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
5732
|
+
return match && match[1] || "";
|
|
5733
|
+
};
|
|
5754
5734
|
|
|
5755
5735
|
const defaultFindOptions = {
|
|
5756
5736
|
startingFrom: ".",
|
|
@@ -5774,8 +5754,9 @@ async function findNearestFile(filename, _options = {}) {
|
|
|
5774
5754
|
segments[0] = "/" + segments[0];
|
|
5775
5755
|
}
|
|
5776
5756
|
let root = segments.findIndex((r) => r.match(options.rootPattern));
|
|
5777
|
-
if (root === -1)
|
|
5757
|
+
if (root === -1) {
|
|
5778
5758
|
root = 0;
|
|
5759
|
+
}
|
|
5779
5760
|
for (let i = segments.length; i > root; i--) {
|
|
5780
5761
|
const filePath = join(...segments.slice(0, i), filename);
|
|
5781
5762
|
if (await options.test(filePath)) {
|
|
@@ -6777,7 +6758,7 @@ function _resolve(id, opts = {}) {
|
|
|
6777
6758
|
if (BUILTIN_MODULES.has(id)) {
|
|
6778
6759
|
return "node:" + id;
|
|
6779
6760
|
}
|
|
6780
|
-
if (isAbsolute
|
|
6761
|
+
if (isAbsolute(id) && existsSync(id)) {
|
|
6781
6762
|
const realPath2 = realpathSync(fileURLToPath(id));
|
|
6782
6763
|
return pathToFileURL(realPath2).toString();
|
|
6783
6764
|
}
|
|
@@ -6891,6 +6872,23 @@ function normalizeModuleId(id) {
|
|
|
6891
6872
|
function isPrimitive(v) {
|
|
6892
6873
|
return v !== Object(v);
|
|
6893
6874
|
}
|
|
6875
|
+
function pathFromRoot(root, filename) {
|
|
6876
|
+
if (isNodeBuiltin(filename))
|
|
6877
|
+
return filename;
|
|
6878
|
+
filename = filename.replace(/^\/@fs\//, isWindows ? "" : "/");
|
|
6879
|
+
if (!filename.startsWith(root))
|
|
6880
|
+
return filename;
|
|
6881
|
+
const relativePath = relative(root, filename);
|
|
6882
|
+
if (!relativePath.startsWith("/") && !relativePath.startsWith("."))
|
|
6883
|
+
return `/${relativePath}`;
|
|
6884
|
+
let index = 0;
|
|
6885
|
+
for (const char of relativePath) {
|
|
6886
|
+
if (char !== "." && char !== "/")
|
|
6887
|
+
return relativePath.slice(index - 1);
|
|
6888
|
+
index++;
|
|
6889
|
+
}
|
|
6890
|
+
return relativePath;
|
|
6891
|
+
}
|
|
6894
6892
|
function toFilePath(id, root) {
|
|
6895
6893
|
let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? resolve$1(root, id.slice(1)) : id;
|
|
6896
6894
|
if (absolute.startsWith("//"))
|
|
@@ -6918,4 +6916,4 @@ function toArray(array) {
|
|
|
6918
6916
|
return [array];
|
|
6919
6917
|
}
|
|
6920
6918
|
|
|
6921
|
-
export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, slash as s, toArray as t, withInlineSourcemap as w };
|
|
6919
|
+
export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, pathFromRoot as p, slash as s, toArray as t, withInlineSourcemap as w };
|
package/dist/cli-wrapper.mjs
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import { p as picocolors } from './
|
|
3
|
-
import { e as execa } from './vendor-index.
|
|
2
|
+
import { p as picocolors, E as EXIT_CODE_RESTART } from './chunk-constants.6196597b.mjs';
|
|
3
|
+
import { e as execa } from './vendor-index.4aeeb598.mjs';
|
|
4
4
|
import 'tty';
|
|
5
|
-
import 'buffer';
|
|
6
5
|
import 'path';
|
|
6
|
+
import 'buffer';
|
|
7
7
|
import 'child_process';
|
|
8
8
|
import 'process';
|
|
9
|
-
import './vendor-index.
|
|
9
|
+
import './vendor-index.62ce5c33.mjs';
|
|
10
10
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
11
11
|
import 'fs';
|
|
12
12
|
import 'stream';
|
|
13
13
|
import 'util';
|
|
14
14
|
import 'os';
|
|
15
|
-
import './vendor-index.
|
|
15
|
+
import './vendor-index.731a22f2.mjs';
|
|
16
16
|
import 'assert';
|
|
17
17
|
import 'events';
|
|
18
18
|
|
|
19
19
|
const ENTRY = new URL("./cli.mjs", import.meta.url);
|
|
20
|
-
const NODE_ARGS = [
|
|
21
|
-
|
|
20
|
+
const NODE_ARGS = [
|
|
21
|
+
"--inspect",
|
|
22
|
+
"--inspect-brk",
|
|
23
|
+
"--trace-deprecation"
|
|
24
|
+
];
|
|
25
|
+
const SegfaultErrors = [
|
|
22
26
|
{
|
|
23
27
|
trigger: "Check failed: result.second.",
|
|
24
28
|
url: "https://github.com/nodejs/node/issues/43617"
|
|
@@ -32,9 +36,9 @@ const ERRORS = [
|
|
|
32
36
|
url: "https://github.com/nodejs/node/issues/42407"
|
|
33
37
|
}
|
|
34
38
|
];
|
|
39
|
+
main();
|
|
35
40
|
async function main() {
|
|
36
41
|
var _a;
|
|
37
|
-
const exitCode = 100;
|
|
38
42
|
let retries = 0;
|
|
39
43
|
const args = process.argv.slice(2);
|
|
40
44
|
if (process.env.VITEST_SEGFAULT_RETRY) {
|
|
@@ -50,23 +54,6 @@ async function main() {
|
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
|
-
retries = Math.max(1, retries || 1);
|
|
54
|
-
for (let i = 1; i <= retries; i++) {
|
|
55
|
-
if (i !== 1)
|
|
56
|
-
console.log(`${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.magenta(" Retrying ")))} vitest ${args.join(" ")} ${picocolors.exports.gray(`(${i} of ${retries})`)}`);
|
|
57
|
-
await start(args);
|
|
58
|
-
if (i === 1 && retries === 1) {
|
|
59
|
-
console.log(picocolors.exports.yellow(`It seems to be an upstream bug of Node.js. To improve the test stability,
|
|
60
|
-
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
|
|
61
|
-
have Vitest auto retries on flaky segfaults.
|
|
62
|
-
`));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
process.exit(exitCode);
|
|
66
|
-
}
|
|
67
|
-
main();
|
|
68
|
-
async function start(args) {
|
|
69
|
-
var _a;
|
|
70
57
|
const nodeArgs = [];
|
|
71
58
|
const vitestArgs = [];
|
|
72
59
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -81,15 +68,49 @@ async function start(args) {
|
|
|
81
68
|
if (!matched)
|
|
82
69
|
vitestArgs.push(args[i]);
|
|
83
70
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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(
|
|
92
|
+
"node",
|
|
93
|
+
[
|
|
94
|
+
...preArgs,
|
|
95
|
+
fileURLToPath(ENTRY),
|
|
96
|
+
...postArgs
|
|
97
|
+
],
|
|
98
|
+
{
|
|
99
|
+
reject: false,
|
|
100
|
+
stderr: "pipe",
|
|
101
|
+
stdout: "inherit",
|
|
102
|
+
stdin: "inherit",
|
|
103
|
+
env: {
|
|
104
|
+
...process.env,
|
|
105
|
+
VITEST_CLI_WRAPPER: "true"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
);
|
|
90
109
|
(_a = child.stderr) == null ? void 0 : _a.pipe(process.stderr);
|
|
91
110
|
const { stderr = "" } = await child;
|
|
92
|
-
|
|
111
|
+
if (child.exitCode === EXIT_CODE_RESTART)
|
|
112
|
+
return "restart";
|
|
113
|
+
for (const error of SegfaultErrors) {
|
|
93
114
|
if (stderr.includes(error.trigger)) {
|
|
94
115
|
if (process.env.GITHUB_ACTIONS)
|
|
95
116
|
console.log(`::warning:: Segmentfault Error Detected: ${error.trigger}
|
|
@@ -100,7 +121,7 @@ ${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.red(" Se
|
|
|
100
121
|
${RED_BLOCK} ${picocolors.exports.red(error.trigger)}
|
|
101
122
|
${RED_BLOCK} ${picocolors.exports.red(`Refer to ${error.url}`)}
|
|
102
123
|
`);
|
|
103
|
-
return;
|
|
124
|
+
return "error";
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
process.exit(child.exitCode);
|
package/dist/cli.mjs
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { p as picocolors } from './
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
2
|
+
import { p as picocolors } from './chunk-constants.6196597b.mjs';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.3035bd5b.mjs';
|
|
4
4
|
import 'tty';
|
|
5
|
-
import '
|
|
5
|
+
import 'url';
|
|
6
6
|
import 'path';
|
|
7
|
+
import './chunk-integrations-coverage.99c020eb.mjs';
|
|
7
8
|
import 'local-pkg';
|
|
8
|
-
import './chunk-
|
|
9
|
+
import './chunk-env-node.ceb43f1c.mjs';
|
|
10
|
+
import 'console';
|
|
11
|
+
import './chunk-mock-date.f63a5ff2.mjs';
|
|
9
12
|
import 'vite';
|
|
10
|
-
import 'url';
|
|
11
13
|
import 'process';
|
|
12
14
|
import 'fs';
|
|
13
|
-
import './chunk-constants.d3f8437b.mjs';
|
|
14
15
|
import 'os';
|
|
15
16
|
import 'util';
|
|
16
17
|
import 'stream';
|
|
17
18
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
18
|
-
import './chunk-vite-node-client.
|
|
19
|
+
import './chunk-vite-node-client.998e04d0.mjs';
|
|
19
20
|
import 'module';
|
|
20
21
|
import 'vm';
|
|
21
|
-
import './chunk-vite-node-utils.
|
|
22
|
+
import './chunk-vite-node-utils.8a9b3014.mjs';
|
|
22
23
|
import 'assert';
|
|
23
24
|
import 'debug';
|
|
25
|
+
import 'perf_hooks';
|
|
24
26
|
import 'worker_threads';
|
|
25
27
|
import 'tinypool';
|
|
26
|
-
import '
|
|
27
|
-
import './chunk-utils-source-map.2a082ffd.mjs';
|
|
28
|
+
import './chunk-utils-source-map.a1647f5f.mjs';
|
|
28
29
|
import './chunk-utils-timers.b48455ed.mjs';
|
|
29
30
|
import 'crypto';
|
|
30
|
-
import './vendor-index.
|
|
31
|
-
import './vendor-index.
|
|
32
|
-
import './chunk-magic-string.
|
|
31
|
+
import './vendor-index.13e3bda3.mjs';
|
|
32
|
+
import './vendor-index.731a22f2.mjs';
|
|
33
|
+
import './chunk-magic-string.56b2b543.mjs';
|
|
34
|
+
import 'strip-literal';
|
|
33
35
|
import 'readline';
|
|
34
36
|
import './vendor-index.ae96af6e.mjs';
|
|
35
37
|
|
|
@@ -650,22 +652,31 @@ const cli = cac("vitest");
|
|
|
650
652
|
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();
|
|
651
653
|
cli.command("run [...filters]").action(run);
|
|
652
654
|
cli.command("related [...filters]").action(runRelated);
|
|
653
|
-
cli.command("watch [...filters]").action(
|
|
654
|
-
cli.command("dev [...filters]").action(
|
|
655
|
-
cli.command("[...filters]").action(
|
|
655
|
+
cli.command("watch [...filters]").action(watch);
|
|
656
|
+
cli.command("dev [...filters]").action(watch);
|
|
657
|
+
cli.command("bench [...filters]").action(benchmark);
|
|
658
|
+
cli.command("[...filters]").action((filters, options) => start("test", filters, options));
|
|
656
659
|
cli.parse();
|
|
657
660
|
async function runRelated(relatedFiles, argv) {
|
|
658
661
|
argv.related = relatedFiles;
|
|
659
662
|
argv.passWithNoTests ?? (argv.passWithNoTests = true);
|
|
660
|
-
await start([], argv);
|
|
663
|
+
await start("test", [], argv);
|
|
664
|
+
}
|
|
665
|
+
async function watch(cliFilters, options) {
|
|
666
|
+
options.watch = true;
|
|
667
|
+
await start("test", cliFilters, options);
|
|
661
668
|
}
|
|
662
669
|
async function run(cliFilters, options) {
|
|
663
670
|
options.run = true;
|
|
664
|
-
await start(cliFilters, options);
|
|
671
|
+
await start("test", cliFilters, options);
|
|
672
|
+
}
|
|
673
|
+
async function benchmark(cliFilters, options) {
|
|
674
|
+
console.warn(picocolors.exports.yellow("Benchmarking is an experimental feature. API might change in the future."));
|
|
675
|
+
await start("benchmark", cliFilters, options);
|
|
665
676
|
}
|
|
666
|
-
async function start(cliFilters, options) {
|
|
677
|
+
async function start(mode, cliFilters, options) {
|
|
667
678
|
try {
|
|
668
|
-
if (await startVitest(cliFilters, options) === false)
|
|
679
|
+
if (await startVitest(mode, cliFilters, options) === false)
|
|
669
680
|
process.exit();
|
|
670
681
|
} catch (e) {
|
|
671
682
|
process.exitCode = 1;
|
package/dist/config.cjs
CHANGED
|
@@ -26,7 +26,7 @@ const coverageConfigDefaults = {
|
|
|
26
26
|
reportsDirectory: "./coverage",
|
|
27
27
|
excludeNodeModules: true,
|
|
28
28
|
exclude: defaultCoverageExcludes,
|
|
29
|
-
reporter: ["text", "html", "clover"],
|
|
29
|
+
reporter: ["text", "html", "clover", "json"],
|
|
30
30
|
allowExternal: false,
|
|
31
31
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
32
32
|
};
|
|
@@ -72,7 +72,7 @@ const config = {
|
|
|
72
72
|
uiBase: "/__vitest__/",
|
|
73
73
|
open: true,
|
|
74
74
|
css: {
|
|
75
|
-
include: [
|
|
75
|
+
include: []
|
|
76
76
|
},
|
|
77
77
|
coverage: coverageConfigDefaults,
|
|
78
78
|
fakeTimers: fakeTimersDefaults,
|
package/dist/config.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
|
|
2
2
|
export { ConfigEnv } from 'vite';
|
|
3
|
-
import { U as UserConfig$1,
|
|
4
|
-
import '
|
|
3
|
+
import { U as UserConfig$1, ad as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './global-ea084c9f.js';
|
|
4
|
+
import 'tinybench';
|
|
5
5
|
import 'fs';
|
|
6
|
+
import 'worker_threads';
|
|
6
7
|
|
|
7
8
|
declare const defaultInclude: string[];
|
|
8
9
|
declare const defaultExclude: string[];
|
|
@@ -31,7 +32,7 @@ declare const config: {
|
|
|
31
32
|
uiBase: string;
|
|
32
33
|
open: boolean;
|
|
33
34
|
css: {
|
|
34
|
-
include:
|
|
35
|
+
include: never[];
|
|
35
36
|
};
|
|
36
37
|
coverage: ResolvedCoverageOptions;
|
|
37
38
|
fakeTimers: FakeTimerInstallOpts;
|
package/dist/config.mjs
CHANGED
|
@@ -22,7 +22,7 @@ const coverageConfigDefaults = {
|
|
|
22
22
|
reportsDirectory: "./coverage",
|
|
23
23
|
excludeNodeModules: true,
|
|
24
24
|
exclude: defaultCoverageExcludes,
|
|
25
|
-
reporter: ["text", "html", "clover"],
|
|
25
|
+
reporter: ["text", "html", "clover", "json"],
|
|
26
26
|
allowExternal: false,
|
|
27
27
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
28
28
|
};
|
|
@@ -68,7 +68,7 @@ const config = {
|
|
|
68
68
|
uiBase: "/__vitest__/",
|
|
69
69
|
open: true,
|
|
70
70
|
css: {
|
|
71
|
-
include: [
|
|
71
|
+
include: []
|
|
72
72
|
},
|
|
73
73
|
coverage: coverageConfigDefaults,
|
|
74
74
|
fakeTimers: fakeTimersDefaults,
|
package/dist/entry.mjs
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
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.
|
|
5
|
-
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
2
|
+
import { g as getWorkerState, a as resetModules } from './chunk-mock-date.f63a5ff2.mjs';
|
|
3
|
+
import { a as envs } from './chunk-env-node.ceb43f1c.mjs';
|
|
4
|
+
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.252dd130.mjs';
|
|
6
5
|
import 'path';
|
|
7
|
-
import './
|
|
6
|
+
import './chunk-constants.6196597b.mjs';
|
|
8
7
|
import 'tty';
|
|
8
|
+
import 'url';
|
|
9
9
|
import 'local-pkg';
|
|
10
|
-
import '
|
|
11
|
-
import '
|
|
10
|
+
import 'console';
|
|
11
|
+
import 'perf_hooks';
|
|
12
|
+
import './chunk-integrations-coverage.99c020eb.mjs';
|
|
13
|
+
import './chunk-runtime-hooks.c6b06bd8.mjs';
|
|
14
|
+
import './chunk-runtime-chain.8bfc559b.mjs';
|
|
12
15
|
import 'util';
|
|
13
16
|
import 'chai';
|
|
14
17
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
15
|
-
import './chunk-runtime-rpc.
|
|
18
|
+
import './chunk-runtime-rpc.48bd94e3.mjs';
|
|
16
19
|
import './chunk-utils-timers.b48455ed.mjs';
|
|
17
|
-
import './chunk-utils-source-map.
|
|
20
|
+
import './chunk-utils-source-map.a1647f5f.mjs';
|
|
18
21
|
import './spy.mjs';
|
|
19
22
|
import 'tinyspy';
|
|
20
23
|
|
|
@@ -30,8 +33,6 @@ async function run(files, config) {
|
|
|
30
33
|
var _a;
|
|
31
34
|
const code = await promises.readFile(file, "utf-8");
|
|
32
35
|
const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
|
|
33
|
-
if (!envs.includes(env))
|
|
34
|
-
throw new Error(`Unsupported environment: "${env}" in ${file}`);
|
|
35
36
|
return {
|
|
36
37
|
file,
|
|
37
38
|
env
|
|
@@ -42,15 +43,20 @@ async function run(files, config) {
|
|
|
42
43
|
acc[env].push(file);
|
|
43
44
|
return acc;
|
|
44
45
|
}, {});
|
|
45
|
-
|
|
46
|
+
const orderedEnvs = envs.concat(
|
|
47
|
+
Object.keys(filesByEnv).filter((env) => !envs.includes(env))
|
|
48
|
+
);
|
|
49
|
+
for (const env of orderedEnvs) {
|
|
46
50
|
const environment = env;
|
|
47
51
|
const files2 = filesByEnv[environment];
|
|
48
52
|
if (!files2 || !files2.length)
|
|
49
53
|
continue;
|
|
50
54
|
await withEnv(environment, config.environmentOptions || {}, async () => {
|
|
51
55
|
for (const file of files2) {
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
if (config.isolate) {
|
|
57
|
+
workerState.mockMap.clear();
|
|
58
|
+
resetModules(workerState.moduleCache, true);
|
|
59
|
+
}
|
|
54
60
|
workerState.filepath = file;
|
|
55
61
|
await startTests([file], config);
|
|
56
62
|
workerState.filepath = void 0;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { a3 as Environment } from './global-ea084c9f.js';
|
|
2
|
+
import 'vite';
|
|
3
|
+
import 'tinybench';
|
|
4
|
+
import 'fs';
|
|
5
|
+
import 'worker_threads';
|
|
6
|
+
|
|
7
|
+
declare const environments: {
|
|
8
|
+
node: Environment;
|
|
9
|
+
jsdom: Environment;
|
|
10
|
+
'happy-dom': Environment;
|
|
11
|
+
'edge-runtime': Environment;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface PopulateOptions {
|
|
15
|
+
bindFunctions?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare function populateGlobal(global: any, win: any, options?: PopulateOptions): {
|
|
18
|
+
keys: Set<string>;
|
|
19
|
+
skipKeys: string[];
|
|
20
|
+
originals: Map<string | symbol, any>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { environments as builtinEnvironments, populateGlobal };
|