vitest 0.0.117 → 0.0.121
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/cli.js +28 -10
- package/dist/{constants-080f26e8.js → constants-22bbd600.js} +1 -1
- package/dist/{diff-80c47cfa.js → diff-a295cb37.js} +1 -1
- package/dist/entry.js +81 -32
- package/dist/{global-d95ee155.js → global-f5814404.js} +5 -5
- package/dist/{index-bf29f0e6.js → index-090545ef.js} +1 -19
- package/dist/{index-33d800eb.js → index-123a18df.js} +60 -36
- package/dist/{index-2b1f526f.js → index-32bc2073.js} +2 -2
- package/dist/index.d.ts +93 -60
- package/dist/index.js +4 -4
- package/dist/{jest-mock-4a754991.js → jest-mock-038a01b3.js} +1 -1
- package/dist/node.d.ts +14 -3
- package/dist/node.js +4 -4
- package/dist/{setup-95b119ff.js → setup-c9c7cb5b.js} +3 -3
- package/dist/utils.js +1 -1
- package/dist/{vi-39f06eb7.js → vi-db2bc738.js} +104 -24
- package/dist/worker.js +36 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7,8 +7,8 @@ import process$1 from 'process';
|
|
|
7
7
|
import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709f57.js';
|
|
8
8
|
import require$$0, { constants } from 'os';
|
|
9
9
|
import { s as signalExit } from './index-648e7ab2.js';
|
|
10
|
-
import { e as ensurePackageInstalled } from './index-
|
|
11
|
-
import { c as createVitest } from './index-
|
|
10
|
+
import { e as ensurePackageInstalled } from './index-090545ef.js';
|
|
11
|
+
import { c as createVitest } from './index-123a18df.js';
|
|
12
12
|
import './_commonjsHelpers-c9e3b764.js';
|
|
13
13
|
import 'fs';
|
|
14
14
|
import 'stream';
|
|
@@ -18,10 +18,10 @@ import 'url';
|
|
|
18
18
|
import 'tty';
|
|
19
19
|
import 'local-pkg';
|
|
20
20
|
import 'vite';
|
|
21
|
-
import './constants-
|
|
21
|
+
import './constants-22bbd600.js';
|
|
22
22
|
import './magic-string.es-94000aea.js';
|
|
23
23
|
import 'perf_hooks';
|
|
24
|
-
import './diff-
|
|
24
|
+
import './diff-a295cb37.js';
|
|
25
25
|
import 'module';
|
|
26
26
|
import 'worker_threads';
|
|
27
27
|
import 'tinypool';
|
|
@@ -1700,10 +1700,11 @@ function execa(file, args, options) {
|
|
|
1700
1700
|
return mergePromise(spawned, handlePromiseOnce);
|
|
1701
1701
|
}
|
|
1702
1702
|
|
|
1703
|
-
var version = "0.0.
|
|
1703
|
+
var version = "0.0.121";
|
|
1704
1704
|
|
|
1705
|
+
const CLOSE_TIMEOUT = 1e3;
|
|
1705
1706
|
const cli = cac("vitest");
|
|
1706
|
-
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("-o, --open", "open UI", { default: false }).option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console output from tests").option("--reporter <name>", "reporter").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
|
|
1707
|
+
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("-o, --open", "open UI", { default: false }).option("-t, --testNamePattern <pattern>", "run test names with the specified pattern").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console output from tests").option("--reporter <name>", "reporter").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--findRelatedTests <filepath>", "run only tests that import specified file").option("--environment <env>", "runner environment", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
|
|
1707
1708
|
cli.command("run [...filters]").action(run);
|
|
1708
1709
|
cli.command("watch [...filters]").action(dev);
|
|
1709
1710
|
cli.command("dev [...filters]").action(dev);
|
|
@@ -1751,18 +1752,35 @@ async function run(cliFilters, options) {
|
|
|
1751
1752
|
await ctx.close();
|
|
1752
1753
|
}
|
|
1753
1754
|
if (!ctx.config.watch) {
|
|
1754
|
-
setTimeout(() => process.exit(),
|
|
1755
|
+
setTimeout(() => process.exit(), CLOSE_TIMEOUT).unref();
|
|
1755
1756
|
}
|
|
1756
1757
|
}
|
|
1758
|
+
function closeServerAndExitProcess(ctx) {
|
|
1759
|
+
const closePromise = ctx.close();
|
|
1760
|
+
let timeout;
|
|
1761
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
1762
|
+
timeout = setTimeout(() => reject(new Error(`close timed out after ${CLOSE_TIMEOUT}ms`)), CLOSE_TIMEOUT);
|
|
1763
|
+
});
|
|
1764
|
+
Promise.race([closePromise, timeoutPromise]).then(() => {
|
|
1765
|
+
clearTimeout(timeout);
|
|
1766
|
+
process.exit(0);
|
|
1767
|
+
}, (err) => {
|
|
1768
|
+
clearTimeout(timeout);
|
|
1769
|
+
console.error("error during close", err);
|
|
1770
|
+
process.exit(1);
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1757
1773
|
function registerConsoleShortcuts(ctx) {
|
|
1758
1774
|
require$$0$1.emitKeypressEvents(process.stdin);
|
|
1759
1775
|
process.stdin.setRawMode(true);
|
|
1760
1776
|
process.stdin.on("keypress", (str, key) => {
|
|
1761
|
-
if (str === "" || str === "" || key && key.ctrl && key.name === "c")
|
|
1762
|
-
|
|
1777
|
+
if (str === "" || str === "" || key && key.ctrl && key.name === "c") {
|
|
1778
|
+
closeServerAndExitProcess(ctx);
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1763
1781
|
if (ctx.runningPromise)
|
|
1764
1782
|
return;
|
|
1765
1783
|
if (ctx.isFirstRun)
|
|
1766
|
-
|
|
1784
|
+
closeServerAndExitProcess(ctx);
|
|
1767
1785
|
});
|
|
1768
1786
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import { k as resolve } from './index-
|
|
2
|
+
import { k as resolve } from './index-090545ef.js';
|
|
3
3
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
5
|
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
package/dist/entry.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import fs, { promises } from 'fs';
|
|
2
|
-
import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn,
|
|
2
|
+
import { b as getState, f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, e as vi } from './vi-db2bc738.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
6
|
import chai$1, { expect, util } from 'chai';
|
|
7
7
|
import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
|
|
8
|
-
import {
|
|
8
|
+
import { u as index, s as slash, v as getNames, c as c$1, t as toArray, r as relative, w as partitionSuiteChildren, x as hasTests, h as hasFailed } from './index-090545ef.js';
|
|
9
9
|
import { r as rpc } from './rpc-8c7cc374.js';
|
|
10
|
-
import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-
|
|
10
|
+
import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-a295cb37.js';
|
|
11
11
|
import { performance } from 'perf_hooks';
|
|
12
12
|
import { createHash } from 'crypto';
|
|
13
13
|
import { format as format$1 } from 'util';
|
|
14
|
-
import './jest-mock-
|
|
14
|
+
import './jest-mock-038a01b3.js';
|
|
15
15
|
import 'tinyspy';
|
|
16
16
|
import 'url';
|
|
17
17
|
import 'tty';
|
|
@@ -2907,7 +2907,7 @@ class SnapshotState {
|
|
|
2907
2907
|
this._dirty = dirty;
|
|
2908
2908
|
this._inlineSnapshots = [];
|
|
2909
2909
|
this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
|
|
2910
|
-
this._counters =
|
|
2910
|
+
this._counters = new Map();
|
|
2911
2911
|
this._index = 0;
|
|
2912
2912
|
this.expand = options.expand || false;
|
|
2913
2913
|
this.added = 0;
|
|
@@ -2944,7 +2944,7 @@ class SnapshotState {
|
|
|
2944
2944
|
}
|
|
2945
2945
|
clear() {
|
|
2946
2946
|
this._snapshotData = this._initialData;
|
|
2947
|
-
this._counters =
|
|
2947
|
+
this._counters = new Map();
|
|
2948
2948
|
this._index = 0;
|
|
2949
2949
|
this.added = 0;
|
|
2950
2950
|
this.matched = 0;
|
|
@@ -3283,18 +3283,19 @@ const isAsyncFunction = (fn) => typeof fn === "function" && fn[Symbol.toStringTa
|
|
|
3283
3283
|
const getMatcherState = (assertion) => {
|
|
3284
3284
|
const actual = assertion._obj;
|
|
3285
3285
|
const isNot = util.flag(assertion, "negate");
|
|
3286
|
+
const promise = util.flag(assertion, "promise") || "";
|
|
3286
3287
|
const jestUtils = __spreadProps(__spreadValues({}, matcherUtils), {
|
|
3287
3288
|
iterableEquality,
|
|
3288
3289
|
subsetEquality
|
|
3289
3290
|
});
|
|
3290
|
-
const matcherState = {
|
|
3291
|
+
const matcherState = __spreadProps(__spreadValues({
|
|
3291
3292
|
isNot,
|
|
3292
3293
|
utils: jestUtils,
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3294
|
+
promise,
|
|
3295
|
+
equals
|
|
3296
|
+
}, getState()), {
|
|
3296
3297
|
suppressedErrors: []
|
|
3297
|
-
};
|
|
3298
|
+
});
|
|
3298
3299
|
return {
|
|
3299
3300
|
state: matcherState,
|
|
3300
3301
|
isNot,
|
|
@@ -3494,22 +3495,18 @@ class StringMatching extends AsymmetricMatcher {
|
|
|
3494
3495
|
}
|
|
3495
3496
|
}
|
|
3496
3497
|
const JestAsymmetricMatchers = (chai, utils) => {
|
|
3498
|
+
utils.addMethod(chai.expect, "anything", () => new Anything());
|
|
3499
|
+
utils.addMethod(chai.expect, "any", (expected) => new Any(expected));
|
|
3497
3500
|
utils.addMethod(chai.expect, "stringContaining", (expected) => new StringContaining(expected));
|
|
3498
|
-
utils.addMethod(chai.expect, "
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
}
|
|
3507
|
-
utils.addMethod(chai.expect, "arrayContaining", (expected) => {
|
|
3508
|
-
return new ArrayContaining(expected);
|
|
3509
|
-
});
|
|
3510
|
-
utils.addMethod(chai.expect, "stringMatching", (expected) => {
|
|
3511
|
-
return new StringMatching(expected);
|
|
3512
|
-
});
|
|
3501
|
+
utils.addMethod(chai.expect, "objectContaining", (expected) => new ObjectContaining(expected));
|
|
3502
|
+
utils.addMethod(chai.expect, "arrayContaining", (expected) => new ArrayContaining(expected));
|
|
3503
|
+
utils.addMethod(chai.expect, "stringMatching", (expected) => new StringMatching(expected));
|
|
3504
|
+
chai.expect.not = {
|
|
3505
|
+
stringContaining: (expected) => new StringContaining(expected, true),
|
|
3506
|
+
objectContaining: (expected) => new ObjectContaining(expected, true),
|
|
3507
|
+
arrayContaining: (expected) => new ArrayContaining(expected, true),
|
|
3508
|
+
stringMatching: (expected) => new StringMatching(expected, true)
|
|
3509
|
+
};
|
|
3513
3510
|
};
|
|
3514
3511
|
|
|
3515
3512
|
let installed = false;
|
|
@@ -3532,7 +3529,7 @@ async function setupGlobalEnv(config) {
|
|
|
3532
3529
|
setupConsoleLogSpy();
|
|
3533
3530
|
await setupChai();
|
|
3534
3531
|
if (config.global)
|
|
3535
|
-
(await import('./global-
|
|
3532
|
+
(await import('./global-f5814404.js')).registerApiGlobally();
|
|
3536
3533
|
}
|
|
3537
3534
|
function setupConsoleLogSpy() {
|
|
3538
3535
|
const stdout = new Writable({
|
|
@@ -3580,7 +3577,7 @@ async function runSetupFiles(config) {
|
|
|
3580
3577
|
}));
|
|
3581
3578
|
}
|
|
3582
3579
|
|
|
3583
|
-
function serializeError(val, seen =
|
|
3580
|
+
function serializeError(val, seen = new WeakSet()) {
|
|
3584
3581
|
if (!val || typeof val === "string")
|
|
3585
3582
|
return val;
|
|
3586
3583
|
if (typeof val === "function")
|
|
@@ -3624,6 +3621,9 @@ function processError(err) {
|
|
|
3624
3621
|
function hash(str, length = 10) {
|
|
3625
3622
|
return createHash("md5").update(str).digest("hex").slice(0, length);
|
|
3626
3623
|
}
|
|
3624
|
+
function inModuleGraph(files) {
|
|
3625
|
+
return files.some((file) => process.__vitest_worker__.moduleCache.has(file));
|
|
3626
|
+
}
|
|
3627
3627
|
async function collectTests(paths, config) {
|
|
3628
3628
|
const files = [];
|
|
3629
3629
|
for (const filepath of paths) {
|
|
@@ -3641,6 +3641,8 @@ async function collectTests(paths, config) {
|
|
|
3641
3641
|
try {
|
|
3642
3642
|
await runSetupFiles(config);
|
|
3643
3643
|
await import(filepath);
|
|
3644
|
+
if (config.findRelatedTests && !inModuleGraph(config.findRelatedTests))
|
|
3645
|
+
continue;
|
|
3644
3646
|
const defaultTasks = await defaultSuite.collect(file);
|
|
3645
3647
|
setHooks(file, getHooks(defaultTasks));
|
|
3646
3648
|
for (const c of [...defaultTasks.tasks, ...context.tasks]) {
|
|
@@ -3663,12 +3665,51 @@ async function collectTests(paths, config) {
|
|
|
3663
3665
|
process.stdout.write("\0");
|
|
3664
3666
|
}
|
|
3665
3667
|
calculateHash(file);
|
|
3668
|
+
interpretTaskModes(file, config.testNamePattern);
|
|
3666
3669
|
files.push(file);
|
|
3667
3670
|
}
|
|
3668
|
-
const tasks = files.reduce((tasks2, file) => tasks2.concat(file.tasks), []);
|
|
3669
|
-
interpretOnlyMode(tasks);
|
|
3670
3671
|
return files;
|
|
3671
3672
|
}
|
|
3673
|
+
function interpretTaskModes(suite, namePattern, onlyMode) {
|
|
3674
|
+
if (onlyMode === void 0)
|
|
3675
|
+
onlyMode = someTasksAreOnly(suite);
|
|
3676
|
+
suite.tasks.forEach((t) => {
|
|
3677
|
+
if (onlyMode) {
|
|
3678
|
+
if (t.type === "suite" && someTasksAreOnly(t)) {
|
|
3679
|
+
if (t.mode === "only")
|
|
3680
|
+
t.mode = "run";
|
|
3681
|
+
interpretTaskModes(t, namePattern, onlyMode);
|
|
3682
|
+
} else if (t.mode === "run") {
|
|
3683
|
+
t.mode = "skip";
|
|
3684
|
+
} else if (t.mode === "only") {
|
|
3685
|
+
t.mode = "run";
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
if (t.type === "test") {
|
|
3689
|
+
if (namePattern && !t.name.match(namePattern))
|
|
3690
|
+
t.mode = "skip";
|
|
3691
|
+
} else if (t.type === "suite") {
|
|
3692
|
+
if (t.mode === "skip")
|
|
3693
|
+
skipAllTasks(t);
|
|
3694
|
+
if (t.mode === "run") {
|
|
3695
|
+
if (t.tasks.every((i) => i.mode !== "run"))
|
|
3696
|
+
t.mode = "skip";
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
});
|
|
3700
|
+
}
|
|
3701
|
+
function someTasksAreOnly(suite) {
|
|
3702
|
+
return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
|
|
3703
|
+
}
|
|
3704
|
+
function skipAllTasks(suite) {
|
|
3705
|
+
suite.tasks.forEach((t) => {
|
|
3706
|
+
if (t.mode === "run") {
|
|
3707
|
+
t.mode = "skip";
|
|
3708
|
+
if (t.type === "suite")
|
|
3709
|
+
skipAllTasks(t);
|
|
3710
|
+
}
|
|
3711
|
+
});
|
|
3712
|
+
}
|
|
3672
3713
|
function calculateHash(parent) {
|
|
3673
3714
|
parent.tasks.forEach((t, idx) => {
|
|
3674
3715
|
t.id = `${parent.id}_${idx}`;
|
|
@@ -3716,11 +3757,19 @@ async function runTest(test) {
|
|
|
3716
3757
|
process.__vitest_worker__.current = test;
|
|
3717
3758
|
try {
|
|
3718
3759
|
await callSuiteHook(test.suite, "beforeEach", [test, test.suite]);
|
|
3719
|
-
setState({
|
|
3760
|
+
setState({
|
|
3761
|
+
assertionCalls: 0,
|
|
3762
|
+
isExpectingAssertions: false,
|
|
3763
|
+
isExpectingAssertionsError: null,
|
|
3764
|
+
expectedAssertionsNumber: null,
|
|
3765
|
+
expectedAssertionsNumberError: null
|
|
3766
|
+
});
|
|
3720
3767
|
await getFn(test)();
|
|
3721
|
-
const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberError } = getState();
|
|
3768
|
+
const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberError, isExpectingAssertions, isExpectingAssertionsError } = getState();
|
|
3722
3769
|
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
3723
3770
|
throw expectedAssertionsNumberError;
|
|
3771
|
+
if (isExpectingAssertions === true && assertionCalls === 0)
|
|
3772
|
+
throw isExpectingAssertionsError;
|
|
3724
3773
|
test.result.state = "pass";
|
|
3725
3774
|
} catch (e) {
|
|
3726
3775
|
test.result.state = "fail";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-22bbd600.js';
|
|
2
|
+
import { i as index } from './index-32bc2073.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './index-
|
|
4
|
+
import './index-090545ef.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
8
|
+
import './vi-db2bc738.js';
|
|
9
9
|
import './_commonjsHelpers-c9e3b764.js';
|
|
10
|
-
import './jest-mock-
|
|
10
|
+
import './jest-mock-038a01b3.js';
|
|
11
11
|
import 'chai';
|
|
12
12
|
import 'tinyspy';
|
|
13
13
|
|
|
@@ -282,24 +282,6 @@ function partitionSuiteChildren(suite) {
|
|
|
282
282
|
tasksGroups.push(tasksGroup);
|
|
283
283
|
return tasksGroups;
|
|
284
284
|
}
|
|
285
|
-
function interpretOnlyMode(tasks) {
|
|
286
|
-
if (tasks.some((t) => t.mode === "only")) {
|
|
287
|
-
tasks.forEach((t) => {
|
|
288
|
-
if (t.mode === "run")
|
|
289
|
-
t.mode = "skip";
|
|
290
|
-
else if (t.mode === "only")
|
|
291
|
-
t.mode = "run";
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
tasks.forEach((t) => {
|
|
295
|
-
if (t.type === "suite") {
|
|
296
|
-
if (t.mode === "skip")
|
|
297
|
-
t.tasks.forEach((c2) => c2.mode === "run" && (c2.mode = "skip"));
|
|
298
|
-
else
|
|
299
|
-
interpretOnlyMode(t.tasks);
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
285
|
function getTests(suite) {
|
|
304
286
|
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
|
|
305
287
|
}
|
|
@@ -383,4 +365,4 @@ function toFilePath(id, root) {
|
|
|
383
365
|
return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
|
|
384
366
|
}
|
|
385
367
|
|
|
386
|
-
export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p,
|
|
368
|
+
export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x, isWindows as y, getTasks as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-
|
|
1
|
+
import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-090545ef.js';
|
|
2
2
|
import { createServer, mergeConfig } from 'vite';
|
|
3
3
|
import path$a from 'path';
|
|
4
4
|
import process$1 from 'process';
|
|
@@ -7,10 +7,10 @@ import require$$0 from 'os';
|
|
|
7
7
|
import require$$0$1 from 'util';
|
|
8
8
|
import require$$0$2 from 'stream';
|
|
9
9
|
import require$$2 from 'events';
|
|
10
|
-
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-
|
|
10
|
+
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-22bbd600.js';
|
|
11
11
|
import MagicString from './magic-string.es-94000aea.js';
|
|
12
12
|
import { performance } from 'perf_hooks';
|
|
13
|
-
import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-
|
|
13
|
+
import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-a295cb37.js';
|
|
14
14
|
import { o as onetime, s as signalExit } from './index-648e7ab2.js';
|
|
15
15
|
import { createRequire } from 'module';
|
|
16
16
|
import { pathToFileURL } from 'url';
|
|
@@ -6847,9 +6847,9 @@ const MocksPlugin = () => {
|
|
|
6847
6847
|
};
|
|
6848
6848
|
};
|
|
6849
6849
|
|
|
6850
|
-
const spinnerMap =
|
|
6850
|
+
const spinnerMap = new WeakMap();
|
|
6851
6851
|
const pointer = c.yellow(F_POINTER);
|
|
6852
|
-
const skipped = c.
|
|
6852
|
+
const skipped = c.dim(c.gray(F_DOWN));
|
|
6853
6853
|
function getCols(delta = 0) {
|
|
6854
6854
|
let length = process.stdout.columns;
|
|
6855
6855
|
if (!length || isNaN(length))
|
|
@@ -6993,8 +6993,8 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
|
|
|
6993
6993
|
if (this.isTTY)
|
|
6994
6994
|
return;
|
|
6995
6995
|
for (const pack of packs) {
|
|
6996
|
-
const task = this.ctx.state.idMap
|
|
6997
|
-
if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
6996
|
+
const task = this.ctx.state.idMap.get(pack[0]);
|
|
6997
|
+
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
6998
6998
|
this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
|
|
6999
6999
|
if (task.result.state === "fail")
|
|
7000
7000
|
this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
@@ -7024,7 +7024,7 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
|
|
|
7024
7024
|
onUserConsoleLog(log) {
|
|
7025
7025
|
if (this.ctx.config.silent)
|
|
7026
7026
|
return;
|
|
7027
|
-
const task = log.taskId ? this.ctx.state.idMap
|
|
7027
|
+
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
7028
7028
|
this.ctx.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
|
|
7029
7029
|
process[log.type].write(`${log.content}
|
|
7030
7030
|
`);
|
|
@@ -7598,7 +7598,7 @@ createLogUpdate(process$1.stderr);
|
|
|
7598
7598
|
|
|
7599
7599
|
const DURATION_LONG = 300;
|
|
7600
7600
|
const MAX_HEIGHT = 20;
|
|
7601
|
-
const outputMap =
|
|
7601
|
+
const outputMap = new WeakMap();
|
|
7602
7602
|
function formatFilepath(path) {
|
|
7603
7603
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
7604
7604
|
const basename = path.slice(lastSlash);
|
|
@@ -7614,10 +7614,10 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7614
7614
|
for (const task of tasks) {
|
|
7615
7615
|
let suffix = "";
|
|
7616
7616
|
const prefix = ` ${getStateSymbol(task)} `;
|
|
7617
|
-
if (task.mode === "skip" || task.mode === "todo")
|
|
7618
|
-
suffix += ` ${c.dim("[skipped]")}`;
|
|
7619
7617
|
if (task.type === "suite")
|
|
7620
7618
|
suffix += c.dim(` (${getTests(task).length})`);
|
|
7619
|
+
if (task.mode === "skip" || task.mode === "todo")
|
|
7620
|
+
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
7621
7621
|
if ((_a = task.result) == null ? void 0 : _a.end) {
|
|
7622
7622
|
const duration = task.result.end - task.result.start;
|
|
7623
7623
|
if (duration > DURATION_LONG)
|
|
@@ -7873,7 +7873,7 @@ function resolveC8Options(options, root) {
|
|
|
7873
7873
|
}
|
|
7874
7874
|
async function cleanCoverage(options, clean = true) {
|
|
7875
7875
|
if (clean && existsSync(options.reportsDirectory))
|
|
7876
|
-
await promises.
|
|
7876
|
+
await promises.rm(options.reportsDirectory, { recursive: true, force: true });
|
|
7877
7877
|
if (!existsSync(options.tempDirectory))
|
|
7878
7878
|
await promises.mkdir(options.tempDirectory, { recursive: true });
|
|
7879
7879
|
}
|
|
@@ -7881,13 +7881,11 @@ const require2 = createRequire(import.meta.url);
|
|
|
7881
7881
|
async function reportCoverage(ctx) {
|
|
7882
7882
|
const createReport = require2("c8/lib/report");
|
|
7883
7883
|
const report = createReport(ctx.config.coverage);
|
|
7884
|
-
await report.getCoverageMapFromAllCoverageFiles();
|
|
7885
7884
|
Array.from(ctx.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/")).forEach(([file, map]) => {
|
|
7886
7885
|
const url = pathToFileURL(file).href;
|
|
7886
|
+
const sources = map.sources.length ? map.sources.map((i) => pathToFileURL(i).href) : [url];
|
|
7887
7887
|
report.sourceMapCache[url] = {
|
|
7888
|
-
data: __spreadProps$1(__spreadValues$1({}, map), {
|
|
7889
|
-
sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
|
|
7890
|
-
})
|
|
7888
|
+
data: __spreadProps$1(__spreadValues$1({}, map), { sources })
|
|
7891
7889
|
};
|
|
7892
7890
|
});
|
|
7893
7891
|
await report.run();
|
|
@@ -7895,25 +7893,25 @@ async function reportCoverage(ctx) {
|
|
|
7895
7893
|
|
|
7896
7894
|
class StateManager {
|
|
7897
7895
|
constructor() {
|
|
7898
|
-
this.filesMap =
|
|
7899
|
-
this.idMap =
|
|
7900
|
-
this.taskFileMap =
|
|
7896
|
+
this.filesMap = new Map();
|
|
7897
|
+
this.idMap = new Map();
|
|
7898
|
+
this.taskFileMap = new WeakMap();
|
|
7901
7899
|
}
|
|
7902
7900
|
getFiles(keys) {
|
|
7903
7901
|
if (keys)
|
|
7904
|
-
return keys.map((key) => this.filesMap
|
|
7905
|
-
return
|
|
7902
|
+
return keys.map((key) => this.filesMap.get(key));
|
|
7903
|
+
return Array.from(this.filesMap.values());
|
|
7906
7904
|
}
|
|
7907
7905
|
collectFiles(files = []) {
|
|
7908
7906
|
files.forEach((file) => {
|
|
7909
|
-
this.filesMap
|
|
7907
|
+
this.filesMap.set(file.filepath, file);
|
|
7910
7908
|
this.updateId(file);
|
|
7911
7909
|
});
|
|
7912
7910
|
}
|
|
7913
7911
|
updateId(task) {
|
|
7914
|
-
if (this.idMap
|
|
7912
|
+
if (this.idMap.get(task.id) === task)
|
|
7915
7913
|
return;
|
|
7916
|
-
this.idMap
|
|
7914
|
+
this.idMap.set(task.id, task);
|
|
7917
7915
|
if (task.type === "suite") {
|
|
7918
7916
|
task.tasks.forEach((task2) => {
|
|
7919
7917
|
this.updateId(task2);
|
|
@@ -7922,8 +7920,8 @@ class StateManager {
|
|
|
7922
7920
|
}
|
|
7923
7921
|
updateTasks(packs) {
|
|
7924
7922
|
for (const [id, result] of packs) {
|
|
7925
|
-
if (this.idMap
|
|
7926
|
-
this.idMap
|
|
7923
|
+
if (this.idMap.has(id))
|
|
7924
|
+
this.idMap.get(id).result = result;
|
|
7927
7925
|
}
|
|
7928
7926
|
}
|
|
7929
7927
|
}
|
|
@@ -7968,6 +7966,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
7968
7966
|
resolved.testTimeout = resolved.testTimeout ?? 5e3;
|
|
7969
7967
|
resolved.hookTimeout = resolved.hookTimeout ?? 1e4;
|
|
7970
7968
|
resolved.isolate = resolved.isolate ?? true;
|
|
7969
|
+
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
7971
7970
|
resolved.watchIgnore = resolved.watchIgnore ?? [/\/node_modules\//, /\/dist\//];
|
|
7972
7971
|
const CI = !!process.env.CI;
|
|
7973
7972
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
@@ -7981,10 +7980,12 @@ function resolveConfig(options, viteConfig) {
|
|
|
7981
7980
|
resolved.setupFiles = Array.from(resolved.setupFiles || []).map((i) => resolve(resolved.root, i));
|
|
7982
7981
|
if (resolved.api === true)
|
|
7983
7982
|
resolved.api = defaultPort;
|
|
7983
|
+
if (options.findRelatedTests)
|
|
7984
|
+
resolved.findRelatedTests = toArray(options.findRelatedTests).map((file) => resolve(resolved.root, file));
|
|
7984
7985
|
return resolved;
|
|
7985
7986
|
}
|
|
7986
7987
|
|
|
7987
|
-
const promiseMap =
|
|
7988
|
+
const promiseMap = new Map();
|
|
7988
7989
|
async function transformRequest(ctx, id) {
|
|
7989
7990
|
if (!promiseMap.has(id)) {
|
|
7990
7991
|
promiseMap.set(id, _transformRequest(ctx, id).then((r) => {
|
|
@@ -8003,10 +8004,24 @@ async function _transformRequest(ctx, id) {
|
|
|
8003
8004
|
if (result)
|
|
8004
8005
|
result = await ctx.server.ssrTransform(result.code, result.map, id);
|
|
8005
8006
|
}
|
|
8007
|
+
if (result)
|
|
8008
|
+
withInlineSourcemap(result);
|
|
8006
8009
|
if ((result == null ? void 0 : result.map) && process.env.NODE_V8_COVERAGE)
|
|
8007
8010
|
ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
|
|
8008
8011
|
return result;
|
|
8009
8012
|
}
|
|
8013
|
+
let SOURCEMAPPING_URL = "sourceMa";
|
|
8014
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
8015
|
+
async function withInlineSourcemap(result) {
|
|
8016
|
+
const { code, map } = result;
|
|
8017
|
+
if (code.includes(`${SOURCEMAPPING_URL}=`))
|
|
8018
|
+
return result;
|
|
8019
|
+
if (map)
|
|
8020
|
+
result.code = `${code}
|
|
8021
|
+
|
|
8022
|
+
//# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}`;
|
|
8023
|
+
return result;
|
|
8024
|
+
}
|
|
8010
8025
|
|
|
8011
8026
|
function createPool(ctx) {
|
|
8012
8027
|
if (ctx.config.threads)
|
|
@@ -8132,9 +8147,9 @@ class Vitest {
|
|
|
8132
8147
|
this.reporters = void 0;
|
|
8133
8148
|
this.outputStream = process.stdout;
|
|
8134
8149
|
this.errorStream = process.stderr;
|
|
8135
|
-
this.invalidates =
|
|
8136
|
-
this.changedTests =
|
|
8137
|
-
this.visitedFilesMap =
|
|
8150
|
+
this.invalidates = new Set();
|
|
8151
|
+
this.changedTests = new Set();
|
|
8152
|
+
this.visitedFilesMap = new Map();
|
|
8138
8153
|
this.isFirstRun = true;
|
|
8139
8154
|
this.restartsCount = 0;
|
|
8140
8155
|
this._onRestartListeners = [];
|
|
@@ -8247,8 +8262,8 @@ class Vitest {
|
|
|
8247
8262
|
const onUnlink = (id) => {
|
|
8248
8263
|
id = slash$1(id);
|
|
8249
8264
|
this.invalidates.add(id);
|
|
8250
|
-
if (
|
|
8251
|
-
|
|
8265
|
+
if (this.state.filesMap.has(id)) {
|
|
8266
|
+
this.state.filesMap.delete(id);
|
|
8252
8267
|
this.changedTests.delete(id);
|
|
8253
8268
|
}
|
|
8254
8269
|
};
|
|
@@ -8277,7 +8292,7 @@ class Vitest {
|
|
|
8277
8292
|
if (!mod)
|
|
8278
8293
|
return;
|
|
8279
8294
|
this.invalidates.add(id);
|
|
8280
|
-
if (
|
|
8295
|
+
if (this.state.filesMap.has(id)) {
|
|
8281
8296
|
this.changedTests.add(id);
|
|
8282
8297
|
return;
|
|
8283
8298
|
}
|
|
@@ -8288,8 +8303,17 @@ class Vitest {
|
|
|
8288
8303
|
}
|
|
8289
8304
|
async close() {
|
|
8290
8305
|
var _a;
|
|
8291
|
-
|
|
8292
|
-
|
|
8306
|
+
if (!this.closingPromise) {
|
|
8307
|
+
this.closingPromise = Promise.allSettled([
|
|
8308
|
+
(_a = this.pool) == null ? void 0 : _a.close(),
|
|
8309
|
+
this.server.close()
|
|
8310
|
+
].filter(Boolean)).then((results) => {
|
|
8311
|
+
results.filter((r) => r.status === "rejected").forEach((err) => {
|
|
8312
|
+
this.error("error during close", err.reason);
|
|
8313
|
+
});
|
|
8314
|
+
});
|
|
8315
|
+
}
|
|
8316
|
+
return this.closingPromise;
|
|
8293
8317
|
}
|
|
8294
8318
|
async report(name, ...args) {
|
|
8295
8319
|
await Promise.all(this.reporters.map((r) => {
|
|
@@ -8335,7 +8359,7 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8335
8359
|
await ctx.setServer(options, server2);
|
|
8336
8360
|
haveStarted = true;
|
|
8337
8361
|
if (options.api)
|
|
8338
|
-
(await import('./setup-
|
|
8362
|
+
(await import('./setup-c9c7cb5b.js')).setup(ctx);
|
|
8339
8363
|
}
|
|
8340
8364
|
},
|
|
8341
8365
|
MocksPlugin()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-db2bc738.js';
|
|
2
2
|
import chai, { assert, should } from 'chai';
|
|
3
|
-
import { s as spies, a as spyOn, f as fn } from './jest-mock-
|
|
3
|
+
import { s as spies, a as spyOn, f as fn } from './jest-mock-038a01b3.js';
|
|
4
4
|
|
|
5
5
|
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
6
6
|
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|