vitest 0.0.94 → 0.0.98
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/bin/vitest.mjs +1 -1
- package/dist/cli.js +15 -10
- package/dist/{constants-9cfa4d7b.js → constants-e78c749a.js} +1 -1
- package/dist/entry.js +45 -23
- package/dist/{error-81292c96.js → error-2437ee7f.js} +6 -4
- package/dist/{global-473089f7.js → global-97ee5fb8.js} +3 -2
- package/dist/{index-de606d4a.js → index-0697046c.js} +19 -16
- package/dist/index-1488b423.js +186 -0
- package/dist/index.d.ts +6 -2
- package/dist/{middleware-bf0f818d.js → middleware-8b68d8d7.js} +3 -2
- package/dist/node.js +6 -5
- package/dist/{utils-576876dc.js → utils-70b78878.js} +1 -1
- package/dist/utils.js +1 -1
- package/dist/worker.js +1320 -343
- package/package.json +4 -4
package/bin/vitest.mjs
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import require$$0 from 'readline';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import {
|
|
4
|
-
import { c as createVitest } from './index-
|
|
3
|
+
import { e as ensurePackageInstalled, c } from './utils-70b78878.js';
|
|
4
|
+
import { c as createVitest } from './index-0697046c.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
|
+
import './index-1488b423.js';
|
|
7
8
|
import 'path';
|
|
8
9
|
import 'vite';
|
|
9
10
|
import 'process';
|
|
10
11
|
import 'fs';
|
|
11
12
|
import 'fast-glob';
|
|
12
13
|
import 'util';
|
|
13
|
-
import './constants-
|
|
14
|
+
import './constants-e78c749a.js';
|
|
14
15
|
import 'url';
|
|
15
16
|
import 'perf_hooks';
|
|
16
|
-
import './error-
|
|
17
|
+
import './error-2437ee7f.js';
|
|
17
18
|
import 'source-map';
|
|
18
19
|
import './index-5cc247ff.js';
|
|
19
20
|
import 'assert';
|
|
20
21
|
import 'worker_threads';
|
|
21
|
-
import '
|
|
22
|
+
import 'tinypool';
|
|
22
23
|
|
|
23
24
|
function toArr(any) {
|
|
24
25
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -633,7 +634,7 @@ class CAC extends EventEmitter {
|
|
|
633
634
|
|
|
634
635
|
const cac = (name = "") => new CAC(name);
|
|
635
636
|
|
|
636
|
-
var version = "0.0.
|
|
637
|
+
var version = "0.0.98";
|
|
637
638
|
|
|
638
639
|
const cli = cac("vitest");
|
|
639
640
|
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 Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", {
|
|
@@ -644,6 +645,7 @@ cli.command("watch [...filters]").action(dev);
|
|
|
644
645
|
cli.command("dev [...filters]").action(dev);
|
|
645
646
|
cli.command("[...filters]").action(dev);
|
|
646
647
|
cli.parse();
|
|
648
|
+
const PROCESS_EXIT_TIMEOUT = 5e3;
|
|
647
649
|
async function dev(cliFilters, argv) {
|
|
648
650
|
if (argv.watch == null)
|
|
649
651
|
argv.watch = !process.env.CI && !process.env.NODE_V8_COVERAGE;
|
|
@@ -652,10 +654,6 @@ async function dev(cliFilters, argv) {
|
|
|
652
654
|
async function run(cliFilters, options) {
|
|
653
655
|
process.env.VITEST = "true";
|
|
654
656
|
process.env.NODE_ENV = "test";
|
|
655
|
-
if (!options.silent) {
|
|
656
|
-
console.log(c.magenta(c.bold("\nVitest is in closed beta exclusively for Sponsors")));
|
|
657
|
-
console.log(c.yellow("Learn more at https://vitest.dev"));
|
|
658
|
-
}
|
|
659
657
|
const ctx = await createVitest(options);
|
|
660
658
|
process.chdir(ctx.config.root);
|
|
661
659
|
registerConsoleShortcuts(ctx);
|
|
@@ -675,6 +673,13 @@ async function run(cliFilters, options) {
|
|
|
675
673
|
if (!ctx.config.watch)
|
|
676
674
|
await ctx.close();
|
|
677
675
|
}
|
|
676
|
+
if (!ctx.config.watch) {
|
|
677
|
+
const timer = setTimeout(() => {
|
|
678
|
+
console.error(c.red("Process hanging for 5 seconds after all tests are done. Exiting..."));
|
|
679
|
+
process.exit(1);
|
|
680
|
+
}, PROCESS_EXIT_TIMEOUT);
|
|
681
|
+
timer.unref();
|
|
682
|
+
}
|
|
678
683
|
}
|
|
679
684
|
function registerConsoleShortcuts(ctx) {
|
|
680
685
|
if (process.stdin.isTTY) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
1
|
import { fileURLToPath } from 'url';
|
|
2
|
+
import { a as resolve } from './index-1488b423.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
|
@@ -4,14 +4,15 @@ import { Writable } from 'stream';
|
|
|
4
4
|
import { importModule } from 'local-pkg';
|
|
5
5
|
import chai, { expect, util } from 'chai';
|
|
6
6
|
import Subset from 'chai-subset';
|
|
7
|
-
import
|
|
7
|
+
import { c as index, b as basename } from './index-1488b423.js';
|
|
8
8
|
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
9
|
-
import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, f as hasTests, h as hasFailed } from './utils-
|
|
10
|
-
import { u as unifiedDiff } from './error-
|
|
9
|
+
import { g as getNames, c as c$1, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, f as hasTests, h as hasFailed } from './utils-70b78878.js';
|
|
10
|
+
import { u as unifiedDiff } from './error-2437ee7f.js';
|
|
11
11
|
import { performance } from 'perf_hooks';
|
|
12
12
|
import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-b8c6cb53.js';
|
|
13
13
|
import { n as nanoid } from './index-9e71c815.js';
|
|
14
14
|
import { format as format$1 } from 'util';
|
|
15
|
+
import 'path';
|
|
15
16
|
import 'tty';
|
|
16
17
|
import 'source-map';
|
|
17
18
|
|
|
@@ -2675,19 +2676,19 @@ let PLUGINS$1 = [
|
|
|
2675
2676
|
];
|
|
2676
2677
|
const getSerializers = () => PLUGINS$1;
|
|
2677
2678
|
|
|
2678
|
-
var __defProp$
|
|
2679
|
-
var __getOwnPropSymbols$
|
|
2680
|
-
var __hasOwnProp$
|
|
2681
|
-
var __propIsEnum$
|
|
2682
|
-
var __defNormalProp$
|
|
2683
|
-
var __spreadValues$
|
|
2679
|
+
var __defProp$2 = Object.defineProperty;
|
|
2680
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2681
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
2682
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
2683
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2684
|
+
var __spreadValues$2 = (a, b) => {
|
|
2684
2685
|
for (var prop in b || (b = {}))
|
|
2685
|
-
if (__hasOwnProp$
|
|
2686
|
-
__defNormalProp$
|
|
2687
|
-
if (__getOwnPropSymbols$
|
|
2688
|
-
for (var prop of __getOwnPropSymbols$
|
|
2689
|
-
if (__propIsEnum$
|
|
2690
|
-
__defNormalProp$
|
|
2686
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
2687
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2688
|
+
if (__getOwnPropSymbols$2)
|
|
2689
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
2690
|
+
if (__propIsEnum$2.call(b, prop))
|
|
2691
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2691
2692
|
}
|
|
2692
2693
|
return a;
|
|
2693
2694
|
};
|
|
@@ -2723,7 +2724,7 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
|
|
|
2723
2724
|
const escapeRegex = true;
|
|
2724
2725
|
const printFunctionName = false;
|
|
2725
2726
|
function serialize(val, indent = 2, formatOverrides = {}) {
|
|
2726
|
-
return normalizeNewlines(format_1(val, __spreadValues$
|
|
2727
|
+
return normalizeNewlines(format_1(val, __spreadValues$2({
|
|
2727
2728
|
escapeRegex,
|
|
2728
2729
|
indent,
|
|
2729
2730
|
plugins: getSerializers(),
|
|
@@ -2738,7 +2739,7 @@ function printBacktickString(str) {
|
|
|
2738
2739
|
}
|
|
2739
2740
|
function ensureDirectoryExists(filePath) {
|
|
2740
2741
|
try {
|
|
2741
|
-
fs.mkdirSync(
|
|
2742
|
+
fs.mkdirSync(index.join(index.dirname(filePath)), { recursive: true });
|
|
2742
2743
|
} catch {
|
|
2743
2744
|
}
|
|
2744
2745
|
}
|
|
@@ -2754,6 +2755,22 @@ ${snapshots.join("\n\n")}
|
|
|
2754
2755
|
`);
|
|
2755
2756
|
}
|
|
2756
2757
|
|
|
2758
|
+
var __defProp$1 = Object.defineProperty;
|
|
2759
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
2760
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
2761
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
2762
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2763
|
+
var __spreadValues$1 = (a, b) => {
|
|
2764
|
+
for (var prop in b || (b = {}))
|
|
2765
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
2766
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2767
|
+
if (__getOwnPropSymbols$1)
|
|
2768
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
2769
|
+
if (__propIsEnum$1.call(b, prop))
|
|
2770
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2771
|
+
}
|
|
2772
|
+
return a;
|
|
2773
|
+
};
|
|
2757
2774
|
class SnapshotState {
|
|
2758
2775
|
constructor(snapshotPath, options) {
|
|
2759
2776
|
this._snapshotPath = snapshotPath;
|
|
@@ -2770,7 +2787,9 @@ class SnapshotState {
|
|
|
2770
2787
|
this.unmatched = 0;
|
|
2771
2788
|
this._updateSnapshot = options.updateSnapshot;
|
|
2772
2789
|
this.updated = 0;
|
|
2773
|
-
this._snapshotFormat =
|
|
2790
|
+
this._snapshotFormat = __spreadValues$1({
|
|
2791
|
+
printBasicPrototype: false
|
|
2792
|
+
}, options.snapshotFormat);
|
|
2774
2793
|
}
|
|
2775
2794
|
markSnapshotsAsCheckedForTest(testName) {
|
|
2776
2795
|
this._uncheckedKeys.forEach((uncheckedKey) => {
|
|
@@ -2899,7 +2918,7 @@ class SnapshotState {
|
|
|
2899
2918
|
}
|
|
2900
2919
|
}
|
|
2901
2920
|
|
|
2902
|
-
const resolveSnapshotPath = (testPath) =>
|
|
2921
|
+
const resolveSnapshotPath = (testPath) => index.join(index.join(index.dirname(testPath), "__snapshots__"), `${index.basename(testPath)}.snap`);
|
|
2903
2922
|
class SnapshotClient {
|
|
2904
2923
|
constructor() {
|
|
2905
2924
|
this.testFile = "";
|
|
@@ -2919,7 +2938,10 @@ class SnapshotClient {
|
|
|
2919
2938
|
assert(received, message, inlineSnapshot) {
|
|
2920
2939
|
if (!this.test)
|
|
2921
2940
|
throw new Error("Snapshot cannot be used outside of test");
|
|
2922
|
-
const testName =
|
|
2941
|
+
const testName = [
|
|
2942
|
+
...getNames(this.test).slice(1),
|
|
2943
|
+
...message ? [message] : []
|
|
2944
|
+
].join(" > ");
|
|
2923
2945
|
const { actual, expected, key, pass } = this.snapshotState.match({
|
|
2924
2946
|
testName,
|
|
2925
2947
|
received,
|
|
@@ -3555,7 +3577,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
3555
3577
|
});
|
|
3556
3578
|
def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
|
|
3557
3579
|
const spy = getSpy(this);
|
|
3558
|
-
const lastCall = spy.calls.
|
|
3580
|
+
const lastCall = spy.calls[spy.calls.length - 1];
|
|
3559
3581
|
this.assert(equals(lastCall, args), "expected last spy call to have been called with #{exp}", "expected last spy call to not have been called with #{exp}", args, lastCall);
|
|
3560
3582
|
});
|
|
3561
3583
|
def(["toThrow", "toThrowError"], function(expected) {
|
|
@@ -3582,7 +3604,7 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
3582
3604
|
});
|
|
3583
3605
|
def(["toHaveLastReturnedWith", "lastReturnedWith"], function(value) {
|
|
3584
3606
|
const spy = getSpy(this);
|
|
3585
|
-
const lastResult = spy.returns.
|
|
3607
|
+
const lastResult = spy.returns[spy.returns.length - 1];
|
|
3586
3608
|
const pass = equals(lastResult, value);
|
|
3587
3609
|
this.assert(pass, "expected last spy call to return #{exp}", "expected last spy call to not return #{exp}", value, lastResult);
|
|
3588
3610
|
});
|
|
@@ -3782,7 +3804,7 @@ async function setupGlobalEnv(config) {
|
|
|
3782
3804
|
setupConsoleLogSpy();
|
|
3783
3805
|
await setupChai();
|
|
3784
3806
|
if (config.global)
|
|
3785
|
-
(await import('./global-
|
|
3807
|
+
(await import('./global-97ee5fb8.js')).registerApiGlobally();
|
|
3786
3808
|
}
|
|
3787
3809
|
function setupConsoleLogSpy() {
|
|
3788
3810
|
const stdout = new Writable({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
|
-
import { relative } from 'path';
|
|
3
2
|
import { format } from 'util';
|
|
4
|
-
import {
|
|
3
|
+
import { r as relative } from './index-1488b423.js';
|
|
4
|
+
import { d as notNullish, c } from './utils-70b78878.js';
|
|
5
5
|
import { SourceMapConsumer } from 'source-map';
|
|
6
6
|
|
|
7
7
|
function Diff() {}
|
|
@@ -1267,12 +1267,14 @@ async function printStack(ctx, stack, highlight, onStack) {
|
|
|
1267
1267
|
const pos = await getSourcePos(ctx, frame) || frame;
|
|
1268
1268
|
const color = frame === highlight ? c.yellow : c.gray;
|
|
1269
1269
|
const path = relative(ctx.config.root, frame.file);
|
|
1270
|
-
|
|
1270
|
+
if (!ctx.config.silent)
|
|
1271
|
+
ctx.console.log(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
|
|
1271
1272
|
await (onStack == null ? void 0 : onStack(frame, pos));
|
|
1272
1273
|
if (frame.file in ctx.state.filesMap)
|
|
1273
1274
|
break;
|
|
1274
1275
|
}
|
|
1275
|
-
ctx.
|
|
1276
|
+
if (!ctx.config.silent)
|
|
1277
|
+
ctx.console.log();
|
|
1276
1278
|
}
|
|
1277
1279
|
function getOriginalPos(map, { line, column }) {
|
|
1278
1280
|
return new Promise((resolve) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
1
|
+
import { g as globalApis } from './constants-e78c749a.js';
|
|
2
2
|
import { i as index } from './index-368448f4.js';
|
|
3
|
-
import 'path';
|
|
4
3
|
import 'url';
|
|
4
|
+
import './index-1488b423.js';
|
|
5
|
+
import 'path';
|
|
5
6
|
import './suite-b8c6cb53.js';
|
|
6
7
|
import './index-9e71c815.js';
|
|
7
8
|
import 'chai';
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { i as isAbsolute, r as relative, d as dirname, b as basename, a as resolve } from './index-1488b423.js';
|
|
2
2
|
import { createServer, mergeConfig } from 'vite';
|
|
3
|
+
import path$2 from 'path';
|
|
3
4
|
import process$1 from 'process';
|
|
4
5
|
import { promises } from 'fs';
|
|
5
6
|
import fg from 'fast-glob';
|
|
6
7
|
import require$$0 from 'util';
|
|
7
|
-
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-
|
|
8
|
-
import { c, g as getNames, s as slash, a as getTests, b as getSuites, n as noop, t as toArray, h as hasFailed } from './utils-
|
|
8
|
+
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-e78c749a.js';
|
|
9
|
+
import { c, g as getNames, s as slash, a as getTests, b as getSuites, n as noop, t as toArray, h as hasFailed } from './utils-70b78878.js';
|
|
9
10
|
import { performance } from 'perf_hooks';
|
|
10
|
-
import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-
|
|
11
|
+
import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-2437ee7f.js';
|
|
11
12
|
import { o as onetime, s as signalExit } from './index-5cc247ff.js';
|
|
12
13
|
import { MessageChannel } from 'worker_threads';
|
|
13
14
|
import { pathToFileURL } from 'url';
|
|
14
|
-
import
|
|
15
|
+
import { Tinypool } from 'tinypool';
|
|
15
16
|
|
|
16
17
|
/*
|
|
17
18
|
How it works:
|
|
@@ -4968,7 +4969,6 @@ class ConsoleReporter {
|
|
|
4968
4969
|
this.ctx = ctx;
|
|
4969
4970
|
this.start = 0;
|
|
4970
4971
|
this.end = 0;
|
|
4971
|
-
this.console = globalThis.console;
|
|
4972
4972
|
this.isFirstWatchRun = true;
|
|
4973
4973
|
const mode = ctx.config.watch ? c.yellow(" DEV ") : c.cyan(" RUN ");
|
|
4974
4974
|
this.log(`
|
|
@@ -4979,12 +4979,12 @@ ${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
|
|
|
4979
4979
|
log(...args) {
|
|
4980
4980
|
if (this.ctx.config.silent)
|
|
4981
4981
|
return;
|
|
4982
|
-
this.console.log(...args);
|
|
4982
|
+
this.ctx.console.log(...args);
|
|
4983
4983
|
}
|
|
4984
4984
|
error(...args) {
|
|
4985
4985
|
if (this.ctx.config.silent)
|
|
4986
4986
|
return;
|
|
4987
|
-
this.console.error(...args);
|
|
4987
|
+
this.ctx.console.error(...args);
|
|
4988
4988
|
}
|
|
4989
4989
|
relative(path) {
|
|
4990
4990
|
return relative(this.ctx.config.root, path);
|
|
@@ -5092,9 +5092,11 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
|
|
|
5092
5092
|
async onWatcherRerun(files, trigger) {
|
|
5093
5093
|
await this.stopListRender();
|
|
5094
5094
|
this.watchFilters = files;
|
|
5095
|
-
this.
|
|
5096
|
-
|
|
5095
|
+
if (!this.ctx.config.silent) {
|
|
5096
|
+
this.ctx.console.clear();
|
|
5097
|
+
this.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
|
|
5097
5098
|
`));
|
|
5099
|
+
}
|
|
5098
5100
|
}
|
|
5099
5101
|
async stopListRender() {
|
|
5100
5102
|
var _a;
|
|
@@ -5183,6 +5185,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
5183
5185
|
resolved.interpretDefault = resolved.interpretDefault ?? true;
|
|
5184
5186
|
resolved.include = resolved.include ?? defaultInclude;
|
|
5185
5187
|
resolved.exclude = resolved.exclude ?? defaultExclude;
|
|
5188
|
+
resolved.watchIgnore = resolved.watchIgnore ?? [/\/node_modules\//, /\/dist\//];
|
|
5186
5189
|
const CI = !!process.env.CI;
|
|
5187
5190
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
5188
5191
|
resolved.snapshotOptions = {
|
|
@@ -5230,7 +5233,7 @@ function createPool(ctx) {
|
|
|
5230
5233
|
else
|
|
5231
5234
|
return createFakePool(ctx);
|
|
5232
5235
|
}
|
|
5233
|
-
const workerPath =
|
|
5236
|
+
const workerPath = pathToFileURL(resolve(distDir, "./worker.js")).href;
|
|
5234
5237
|
function createFakePool(ctx) {
|
|
5235
5238
|
const runWithFiles = (name) => {
|
|
5236
5239
|
return async (files, invalidates) => {
|
|
@@ -5263,7 +5266,7 @@ function createWorkerPool(ctx) {
|
|
|
5263
5266
|
options.maxThreads = ctx.config.maxThreads;
|
|
5264
5267
|
if (ctx.config.minThreads != null)
|
|
5265
5268
|
options.minThreads = ctx.config.minThreads;
|
|
5266
|
-
const
|
|
5269
|
+
const pool = new Tinypool(options);
|
|
5267
5270
|
const runWithFiles = (name) => {
|
|
5268
5271
|
return async (files, invalidates) => {
|
|
5269
5272
|
await Promise.all(files.map(async (file) => {
|
|
@@ -5274,7 +5277,7 @@ function createWorkerPool(ctx) {
|
|
|
5274
5277
|
files: [file],
|
|
5275
5278
|
invalidates
|
|
5276
5279
|
};
|
|
5277
|
-
await
|
|
5280
|
+
await pool.run(data, { transferList: [workerPort], name });
|
|
5278
5281
|
port.close();
|
|
5279
5282
|
workerPort.close();
|
|
5280
5283
|
}));
|
|
@@ -5283,7 +5286,7 @@ function createWorkerPool(ctx) {
|
|
|
5283
5286
|
return {
|
|
5284
5287
|
runTests: runWithFiles("run"),
|
|
5285
5288
|
collectTests: runWithFiles("collect"),
|
|
5286
|
-
close: () =>
|
|
5289
|
+
close: () => pool.destroy()
|
|
5287
5290
|
};
|
|
5288
5291
|
}
|
|
5289
5292
|
function createChannel(ctx) {
|
|
@@ -5449,7 +5452,7 @@ class Vitest {
|
|
|
5449
5452
|
};
|
|
5450
5453
|
}
|
|
5451
5454
|
handleFileChanged(id) {
|
|
5452
|
-
if (this.changedTests.has(id) || this.invalidates.has(id) ||
|
|
5455
|
+
if (this.changedTests.has(id) || this.invalidates.has(id) || this.config.watchIgnore.some((i) => id.match(i)))
|
|
5453
5456
|
return;
|
|
5454
5457
|
this.invalidates.add(id);
|
|
5455
5458
|
if (id in this.state.filesMap) {
|
|
@@ -5513,7 +5516,7 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
5513
5516
|
ctx.setServer(options, server2);
|
|
5514
5517
|
haveStarted = true;
|
|
5515
5518
|
if (options.api)
|
|
5516
|
-
server2.middlewares.use((await import('./middleware-
|
|
5519
|
+
server2.middlewares.use((await import('./middleware-8b68d8d7.js')).default(ctx));
|
|
5517
5520
|
}
|
|
5518
5521
|
}
|
|
5519
5522
|
],
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
function normalizeWindowsPath(input = "") {
|
|
4
|
+
if (!input.includes("\\")) {
|
|
5
|
+
return input;
|
|
6
|
+
}
|
|
7
|
+
return input.replace(/\\/g, "/");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const _UNC_REGEX = /^[/][/]/;
|
|
11
|
+
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
|
|
12
|
+
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
|
|
13
|
+
const sep = "/";
|
|
14
|
+
const delimiter = ":";
|
|
15
|
+
const normalize = function(path2) {
|
|
16
|
+
if (path2.length === 0) {
|
|
17
|
+
return ".";
|
|
18
|
+
}
|
|
19
|
+
path2 = normalizeWindowsPath(path2);
|
|
20
|
+
const isUNCPath = path2.match(_UNC_REGEX);
|
|
21
|
+
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
|
|
22
|
+
const isPathAbsolute = isAbsolute(path2);
|
|
23
|
+
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
24
|
+
path2 = normalizeString(path2, !isPathAbsolute);
|
|
25
|
+
if (path2.length === 0) {
|
|
26
|
+
if (isPathAbsolute) {
|
|
27
|
+
return "/";
|
|
28
|
+
}
|
|
29
|
+
return trailingSeparator ? "./" : ".";
|
|
30
|
+
}
|
|
31
|
+
if (trailingSeparator) {
|
|
32
|
+
path2 += "/";
|
|
33
|
+
}
|
|
34
|
+
if (isUNCPath) {
|
|
35
|
+
if (hasUNCDrive) {
|
|
36
|
+
return `//./${path2}`;
|
|
37
|
+
}
|
|
38
|
+
return `//${path2}`;
|
|
39
|
+
}
|
|
40
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
41
|
+
};
|
|
42
|
+
const join = function(...args) {
|
|
43
|
+
if (args.length === 0) {
|
|
44
|
+
return ".";
|
|
45
|
+
}
|
|
46
|
+
let joined;
|
|
47
|
+
for (let i = 0; i < args.length; ++i) {
|
|
48
|
+
const arg = args[i];
|
|
49
|
+
if (arg.length > 0) {
|
|
50
|
+
if (joined === void 0) {
|
|
51
|
+
joined = arg;
|
|
52
|
+
} else {
|
|
53
|
+
joined += `/${arg}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (joined === void 0) {
|
|
58
|
+
return ".";
|
|
59
|
+
}
|
|
60
|
+
return normalize(joined);
|
|
61
|
+
};
|
|
62
|
+
const resolve = function(...args) {
|
|
63
|
+
args = args.map((arg) => normalizeWindowsPath(arg));
|
|
64
|
+
let resolvedPath = "";
|
|
65
|
+
let resolvedAbsolute = false;
|
|
66
|
+
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
67
|
+
const path2 = i >= 0 ? args[i] : process.cwd();
|
|
68
|
+
if (path2.length === 0) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
resolvedPath = `${path2}/${resolvedPath}`;
|
|
72
|
+
resolvedAbsolute = isAbsolute(path2);
|
|
73
|
+
}
|
|
74
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
75
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
76
|
+
return `/${resolvedPath}`;
|
|
77
|
+
}
|
|
78
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
79
|
+
};
|
|
80
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
81
|
+
let res = "";
|
|
82
|
+
let lastSegmentLength = 0;
|
|
83
|
+
let lastSlash = -1;
|
|
84
|
+
let dots = 0;
|
|
85
|
+
let char = null;
|
|
86
|
+
for (let i = 0; i <= path2.length; ++i) {
|
|
87
|
+
if (i < path2.length) {
|
|
88
|
+
char = path2[i];
|
|
89
|
+
} else if (char === "/") {
|
|
90
|
+
break;
|
|
91
|
+
} else {
|
|
92
|
+
char = "/";
|
|
93
|
+
}
|
|
94
|
+
if (char === "/") {
|
|
95
|
+
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
|
|
96
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
97
|
+
if (res.length > 2) {
|
|
98
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
99
|
+
if (lastSlashIndex === -1) {
|
|
100
|
+
res = "";
|
|
101
|
+
lastSegmentLength = 0;
|
|
102
|
+
} else {
|
|
103
|
+
res = res.slice(0, lastSlashIndex);
|
|
104
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
105
|
+
}
|
|
106
|
+
lastSlash = i;
|
|
107
|
+
dots = 0;
|
|
108
|
+
continue;
|
|
109
|
+
} else if (res.length !== 0) {
|
|
110
|
+
res = "";
|
|
111
|
+
lastSegmentLength = 0;
|
|
112
|
+
lastSlash = i;
|
|
113
|
+
dots = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (allowAboveRoot) {
|
|
118
|
+
res += res.length > 0 ? "/.." : "..";
|
|
119
|
+
lastSegmentLength = 2;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
if (res.length > 0) {
|
|
123
|
+
res += `/${path2.slice(lastSlash + 1, i)}`;
|
|
124
|
+
} else {
|
|
125
|
+
res = path2.slice(lastSlash + 1, i);
|
|
126
|
+
}
|
|
127
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
128
|
+
}
|
|
129
|
+
lastSlash = i;
|
|
130
|
+
dots = 0;
|
|
131
|
+
} else if (char === "." && dots !== -1) {
|
|
132
|
+
++dots;
|
|
133
|
+
} else {
|
|
134
|
+
dots = -1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return res;
|
|
138
|
+
}
|
|
139
|
+
const isAbsolute = function(p) {
|
|
140
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
141
|
+
};
|
|
142
|
+
const toNamespacedPath = function(p) {
|
|
143
|
+
return normalizeWindowsPath(p);
|
|
144
|
+
};
|
|
145
|
+
const extname = function(p) {
|
|
146
|
+
return path.posix.extname(normalizeWindowsPath(p));
|
|
147
|
+
};
|
|
148
|
+
const relative = function(from, to) {
|
|
149
|
+
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
|
|
150
|
+
};
|
|
151
|
+
const dirname = function(p) {
|
|
152
|
+
return path.posix.dirname(normalizeWindowsPath(p));
|
|
153
|
+
};
|
|
154
|
+
const format = function(p) {
|
|
155
|
+
return normalizeWindowsPath(path.posix.format(p));
|
|
156
|
+
};
|
|
157
|
+
const basename = function(p, ext) {
|
|
158
|
+
return path.posix.basename(normalizeWindowsPath(p), ext);
|
|
159
|
+
};
|
|
160
|
+
const parse = function(p) {
|
|
161
|
+
return path.posix.parse(normalizeWindowsPath(p));
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const _path = /*#__PURE__*/Object.freeze({
|
|
165
|
+
__proto__: null,
|
|
166
|
+
sep: sep,
|
|
167
|
+
delimiter: delimiter,
|
|
168
|
+
normalize: normalize,
|
|
169
|
+
join: join,
|
|
170
|
+
resolve: resolve,
|
|
171
|
+
normalizeString: normalizeString,
|
|
172
|
+
isAbsolute: isAbsolute,
|
|
173
|
+
toNamespacedPath: toNamespacedPath,
|
|
174
|
+
extname: extname,
|
|
175
|
+
relative: relative,
|
|
176
|
+
dirname: dirname,
|
|
177
|
+
format: format,
|
|
178
|
+
basename: basename,
|
|
179
|
+
parse: parse
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const index = {
|
|
183
|
+
..._path
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export { resolve as a, basename as b, index as c, dirname as d, isAbsolute as i, relative as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -420,6 +420,12 @@ interface InlineConfig {
|
|
|
420
420
|
* Path to setup files
|
|
421
421
|
*/
|
|
422
422
|
setupFiles?: string | string[];
|
|
423
|
+
/**
|
|
424
|
+
* Pattern of file paths to be ignore from triggering watch rerun
|
|
425
|
+
*
|
|
426
|
+
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
427
|
+
*/
|
|
428
|
+
watchIgnore?: (string | RegExp)[];
|
|
423
429
|
/**
|
|
424
430
|
* Open Vitest UI
|
|
425
431
|
* @internal WIP
|
|
@@ -469,8 +475,6 @@ interface RpcMap {
|
|
|
469
475
|
onCollected: [[files: File[]], void];
|
|
470
476
|
onFinished: [[], void];
|
|
471
477
|
onTaskUpdate: [[pack: TaskResultPack], void];
|
|
472
|
-
onWatcherStart: [[], void];
|
|
473
|
-
onWatcherRerun: [[files: string[], trigger: string], void];
|
|
474
478
|
snapshotSaved: [[snapshot: SnapshotResult], void];
|
|
475
479
|
}
|
|
476
480
|
declare type RpcCall = <T extends keyof RpcMap>(method: T, ...args: RpcMap[T][0]) => Promise<RpcMap[T][1]>;
|
package/dist/node.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
1
|
+
export { c as createVitest } from './index-0697046c.js';
|
|
2
|
+
import './index-1488b423.js';
|
|
2
3
|
import 'path';
|
|
3
4
|
import 'vite';
|
|
4
5
|
import 'process';
|
|
5
6
|
import 'fs';
|
|
6
7
|
import 'fast-glob';
|
|
7
8
|
import 'util';
|
|
8
|
-
import './constants-
|
|
9
|
+
import './constants-e78c749a.js';
|
|
9
10
|
import 'url';
|
|
10
|
-
import './utils-
|
|
11
|
+
import './utils-70b78878.js';
|
|
11
12
|
import 'tty';
|
|
12
13
|
import 'local-pkg';
|
|
13
14
|
import 'perf_hooks';
|
|
14
|
-
import './error-
|
|
15
|
+
import './error-2437ee7f.js';
|
|
15
16
|
import 'source-map';
|
|
16
17
|
import './index-5cc247ff.js';
|
|
17
18
|
import 'assert';
|
|
18
19
|
import 'events';
|
|
19
20
|
import 'worker_threads';
|
|
20
|
-
import '
|
|
21
|
+
import 'tinypool';
|
|
@@ -153,7 +153,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
|
|
|
153
153
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
154
154
|
});
|
|
155
155
|
if (install) {
|
|
156
|
-
await (await import('./index-e7a421bb.js')).installPackage(dependency);
|
|
156
|
+
await (await import('./index-e7a421bb.js')).installPackage(dependency, { dev: true });
|
|
157
157
|
return true;
|
|
158
158
|
}
|
|
159
159
|
return false;
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { e as ensurePackageInstalled, g as getNames, b as getSuites, j as getTasks, a as getTests, h as hasFailed, f as hasTests, i as interpretOnlyMode, n as noop, d as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-
|
|
1
|
+
export { e as ensurePackageInstalled, g as getNames, b as getSuites, j as getTasks, a as getTests, h as hasFailed, f as hasTests, i as interpretOnlyMode, n as noop, d as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-70b78878.js';
|
|
2
2
|
import 'local-pkg';
|
|
3
3
|
import 'tty';
|