vitest 0.0.114 → 0.0.118
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 +32 -33
- package/dist/cli.js +1111 -34
- package/dist/{constants-9c7f06df.js → constants-56bfb5ab.js} +1 -1
- package/dist/{diff-3cfdad26.js → diff-d87307c6.js} +1 -1
- package/dist/entry.js +85 -22
- package/dist/{global-12653c72.js → global-fc93e939.js} +4 -4
- package/dist/{index-36694964.js → index-62869b66.js} +182 -144
- package/dist/{index-61c8686f.js → index-648e7ab2.js} +62 -62
- package/dist/index-6e709f57.js +781 -0
- package/dist/{index-ea5153a0.js → index-80671389.js} +29 -21
- package/dist/{index-ebf35a56.js → index-be3cc31e.js} +1 -1
- package/dist/{index-9f4b9905.js → index-ce49e384.js} +33 -800
- package/dist/{index-7889832e.js → index-e909c175.js} +25 -16
- package/dist/index.d.ts +99 -23
- package/dist/index.js +3 -3
- package/dist/node.d.ts +86 -19
- package/dist/node.js +8 -7
- package/dist/rpc-8c7cc374.js +5 -0
- package/dist/setup-b87afd31.js +4318 -0
- package/dist/utils.js +1 -1
- package/dist/{vi-67e478ef.js → vi-85b65e90.js} +30 -17
- package/dist/worker.js +8 -7
- package/package.json +7 -7
- package/vitest.mjs +1 -20
- package/dist/middleware-85ff8fbf.js +0 -81
- package/dist/rpc-85fe6402.js +0 -10
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { pathToFileURL } from 'url';
|
|
3
|
-
import { c, s as slash$1, i as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, a as getSuites, f as getTests, j as resolve, t as toFilePath, n as noop$1, k as toArray, l as join } from './index-ea5153a0.js';
|
|
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-80671389.js';
|
|
4
2
|
import { createServer, mergeConfig } from 'vite';
|
|
5
3
|
import path$a from 'path';
|
|
6
4
|
import process$1 from 'process';
|
|
5
|
+
import fs$8, { promises, existsSync } from 'fs';
|
|
7
6
|
import require$$0 from 'os';
|
|
8
7
|
import require$$0$1 from 'util';
|
|
9
8
|
import require$$0$2 from 'stream';
|
|
10
9
|
import require$$2 from 'events';
|
|
11
|
-
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-56bfb5ab.js';
|
|
12
11
|
import MagicString from './magic-string.es-94000aea.js';
|
|
13
|
-
import { performance
|
|
14
|
-
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-
|
|
15
|
-
import { o as onetime, s as signalExit } from './index-
|
|
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-d87307c6.js';
|
|
14
|
+
import { o as onetime, s as signalExit } from './index-648e7ab2.js';
|
|
15
|
+
import { createRequire } from 'module';
|
|
16
|
+
import { pathToFileURL } from 'url';
|
|
16
17
|
import { MessageChannel } from 'worker_threads';
|
|
17
18
|
import { Tinypool } from 'tinypool';
|
|
18
|
-
import { c as createBirpc } from './index-
|
|
19
|
+
import { c as createBirpc } from './index-e909c175.js';
|
|
19
20
|
|
|
20
21
|
/*
|
|
21
22
|
How it works:
|
|
@@ -6848,7 +6849,7 @@ const MocksPlugin = () => {
|
|
|
6848
6849
|
|
|
6849
6850
|
const spinnerMap = /* @__PURE__ */ new WeakMap();
|
|
6850
6851
|
const pointer = c.yellow(F_POINTER);
|
|
6851
|
-
const skipped = c.
|
|
6852
|
+
const skipped = c.dim(c.gray(F_DOWN));
|
|
6852
6853
|
function getCols(delta = 0) {
|
|
6853
6854
|
let length = process.stdout.columns;
|
|
6854
6855
|
if (!length || isNaN(length))
|
|
@@ -6965,34 +6966,39 @@ function elegantSpinner() {
|
|
|
6965
6966
|
}
|
|
6966
6967
|
|
|
6967
6968
|
class BaseReporter {
|
|
6968
|
-
constructor(
|
|
6969
|
-
this.ctx = ctx;
|
|
6969
|
+
constructor() {
|
|
6970
6970
|
this.start = 0;
|
|
6971
6971
|
this.end = 0;
|
|
6972
6972
|
this.isTTY = process.stdout.isTTY && !process.env.CI;
|
|
6973
|
+
this.ctx = void 0;
|
|
6973
6974
|
this.isFirstWatchRun = true;
|
|
6974
|
-
|
|
6975
|
+
}
|
|
6976
|
+
onInit(ctx) {
|
|
6977
|
+
this.ctx = ctx;
|
|
6978
|
+
const mode = this.ctx.config.watch ? c.blue(" WATCH ") : c.cyan(" RUN ");
|
|
6975
6979
|
this.ctx.log(`
|
|
6976
6980
|
${c.inverse(c.bold(mode))} ${c.gray(this.ctx.config.root)}
|
|
6977
6981
|
`);
|
|
6978
|
-
this.start = performance
|
|
6982
|
+
this.start = performance.now();
|
|
6979
6983
|
}
|
|
6980
6984
|
relative(path) {
|
|
6981
6985
|
return relative(this.ctx.config.root, path);
|
|
6982
6986
|
}
|
|
6983
6987
|
async onFinished(files = this.ctx.state.getFiles()) {
|
|
6984
|
-
this.end = performance
|
|
6988
|
+
this.end = performance.now();
|
|
6985
6989
|
await this.reportSummary(files);
|
|
6986
6990
|
}
|
|
6987
|
-
onTaskUpdate(
|
|
6991
|
+
onTaskUpdate(packs) {
|
|
6988
6992
|
var _a, _b, _c;
|
|
6989
6993
|
if (this.isTTY)
|
|
6990
6994
|
return;
|
|
6991
|
-
const
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6995
|
+
for (const pack of packs) {
|
|
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
|
+
this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
|
|
6999
|
+
if (task.result.state === "fail")
|
|
7000
|
+
this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
7001
|
+
}
|
|
6996
7002
|
}
|
|
6997
7003
|
}
|
|
6998
7004
|
async onWatcherStart() {
|
|
@@ -7011,13 +7017,14 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
|
|
|
7011
7017
|
async onWatcherRerun(files, trigger) {
|
|
7012
7018
|
this.watchFilters = files;
|
|
7013
7019
|
this.ctx.console.clear();
|
|
7014
|
-
this.ctx.log(c.blue("Re-running tests...") + c.dim(` [ ${this.relative(trigger)} ]
|
|
7015
|
-
`));
|
|
7020
|
+
this.ctx.log(c.blue("Re-running tests...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
7021
|
+
`) : ""));
|
|
7022
|
+
this.start = performance.now();
|
|
7016
7023
|
}
|
|
7017
7024
|
onUserConsoleLog(log) {
|
|
7018
7025
|
if (this.ctx.config.silent)
|
|
7019
7026
|
return;
|
|
7020
|
-
const task = log.taskId ? this.ctx.state.idMap
|
|
7027
|
+
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
7021
7028
|
this.ctx.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
|
|
7022
7029
|
process[log.type].write(`${log.content}
|
|
7023
7030
|
`);
|
|
@@ -7607,10 +7614,10 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7607
7614
|
for (const task of tasks) {
|
|
7608
7615
|
let suffix = "";
|
|
7609
7616
|
const prefix = ` ${getStateSymbol(task)} `;
|
|
7610
|
-
if (task.mode === "skip" || task.mode === "todo")
|
|
7611
|
-
suffix += ` ${c.dim("[skipped]")}`;
|
|
7612
7617
|
if (task.type === "suite")
|
|
7613
7618
|
suffix += c.dim(` (${getTests(task).length})`);
|
|
7619
|
+
if (task.mode === "skip" || task.mode === "todo")
|
|
7620
|
+
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
7614
7621
|
if ((_a = task.result) == null ? void 0 : _a.end) {
|
|
7615
7622
|
const duration = task.result.end - task.result.start;
|
|
7616
7623
|
if (duration > DURATION_LONG)
|
|
@@ -7639,11 +7646,10 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7639
7646
|
}
|
|
7640
7647
|
return output.slice(0, MAX_HEIGHT).join("\n");
|
|
7641
7648
|
}
|
|
7642
|
-
const createListRenderer = (_tasks, options
|
|
7649
|
+
const createListRenderer = (_tasks, options) => {
|
|
7643
7650
|
let tasks = _tasks;
|
|
7644
7651
|
let timer;
|
|
7645
|
-
const
|
|
7646
|
-
const log = createLogUpdate(stdout);
|
|
7652
|
+
const log = createLogUpdate(options.outputStream);
|
|
7647
7653
|
function update() {
|
|
7648
7654
|
log(renderTree(tasks, options));
|
|
7649
7655
|
}
|
|
@@ -7665,7 +7671,7 @@ const createListRenderer = (_tasks, options = {}) => {
|
|
|
7665
7671
|
timer = void 0;
|
|
7666
7672
|
}
|
|
7667
7673
|
log.clear();
|
|
7668
|
-
|
|
7674
|
+
options.outputStream.write(`${renderTree(tasks, options)}
|
|
7669
7675
|
`);
|
|
7670
7676
|
return this;
|
|
7671
7677
|
},
|
|
@@ -7680,8 +7686,9 @@ class DefaultReporter extends BaseReporter {
|
|
|
7680
7686
|
super(...arguments);
|
|
7681
7687
|
this.rendererOptions = {};
|
|
7682
7688
|
}
|
|
7683
|
-
|
|
7689
|
+
onCollected() {
|
|
7684
7690
|
if (this.isTTY) {
|
|
7691
|
+
this.rendererOptions.outputStream = this.ctx.outputStream;
|
|
7685
7692
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
7686
7693
|
if (!this.renderer)
|
|
7687
7694
|
this.renderer = createListRenderer(files, this.rendererOptions).start();
|
|
@@ -7700,9 +7707,8 @@ class DefaultReporter extends BaseReporter {
|
|
|
7700
7707
|
}
|
|
7701
7708
|
async stopListRender() {
|
|
7702
7709
|
var _a;
|
|
7703
|
-
(_a = this.renderer) == null ? void 0 : _a.stop();
|
|
7710
|
+
await ((_a = this.renderer) == null ? void 0 : _a.stop());
|
|
7704
7711
|
this.renderer = void 0;
|
|
7705
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
7706
7712
|
}
|
|
7707
7713
|
async onWatcherRerun(files, trigger) {
|
|
7708
7714
|
await this.stopListRender();
|
|
@@ -7735,11 +7741,10 @@ function render(tasks) {
|
|
|
7735
7741
|
}
|
|
7736
7742
|
}).join("");
|
|
7737
7743
|
}
|
|
7738
|
-
const createDotRenderer = (_tasks) => {
|
|
7744
|
+
const createDotRenderer = (_tasks, options) => {
|
|
7739
7745
|
let tasks = _tasks;
|
|
7740
7746
|
let timer;
|
|
7741
|
-
const
|
|
7742
|
-
const log = createLogUpdate(stdout);
|
|
7747
|
+
const log = createLogUpdate(options.outputStream);
|
|
7743
7748
|
function update() {
|
|
7744
7749
|
log(render(tasks));
|
|
7745
7750
|
}
|
|
@@ -7761,7 +7766,7 @@ const createDotRenderer = (_tasks) => {
|
|
|
7761
7766
|
timer = void 0;
|
|
7762
7767
|
}
|
|
7763
7768
|
log.clear();
|
|
7764
|
-
|
|
7769
|
+
options.outputStream.write(`${render(tasks)}
|
|
7765
7770
|
`);
|
|
7766
7771
|
return this;
|
|
7767
7772
|
},
|
|
@@ -7772,11 +7777,11 @@ const createDotRenderer = (_tasks) => {
|
|
|
7772
7777
|
};
|
|
7773
7778
|
|
|
7774
7779
|
class DotReporter extends BaseReporter {
|
|
7775
|
-
|
|
7780
|
+
onCollected() {
|
|
7776
7781
|
if (this.isTTY) {
|
|
7777
7782
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
7778
7783
|
if (!this.renderer)
|
|
7779
|
-
this.renderer = createDotRenderer(files).start();
|
|
7784
|
+
this.renderer = createDotRenderer(files, { outputStream: this.ctx.outputStream }).start();
|
|
7780
7785
|
else
|
|
7781
7786
|
this.renderer.update(files);
|
|
7782
7787
|
}
|
|
@@ -7808,8 +7813,8 @@ class DotReporter extends BaseReporter {
|
|
|
7808
7813
|
}
|
|
7809
7814
|
|
|
7810
7815
|
class VerboseReporter extends DefaultReporter {
|
|
7811
|
-
constructor(
|
|
7812
|
-
super(
|
|
7816
|
+
constructor() {
|
|
7817
|
+
super();
|
|
7813
7818
|
this.rendererOptions.renderSucceed = true;
|
|
7814
7819
|
}
|
|
7815
7820
|
}
|
|
@@ -7820,27 +7825,95 @@ const ReportersMap = {
|
|
|
7820
7825
|
dot: DotReporter
|
|
7821
7826
|
};
|
|
7822
7827
|
|
|
7828
|
+
var __defProp$1 = Object.defineProperty;
|
|
7829
|
+
var __defProps$1 = Object.defineProperties;
|
|
7830
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
7831
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
7832
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
7833
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
7834
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7835
|
+
var __spreadValues$1 = (a, b) => {
|
|
7836
|
+
for (var prop in b || (b = {}))
|
|
7837
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
7838
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
7839
|
+
if (__getOwnPropSymbols$1)
|
|
7840
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
7841
|
+
if (__propIsEnum$1.call(b, prop))
|
|
7842
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
7843
|
+
}
|
|
7844
|
+
return a;
|
|
7845
|
+
};
|
|
7846
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
7847
|
+
const defaultExcludes = [
|
|
7848
|
+
"coverage/**",
|
|
7849
|
+
"packages/*/test{,s}/**",
|
|
7850
|
+
"**/*.d.ts",
|
|
7851
|
+
"test{,s}/**",
|
|
7852
|
+
"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
|
|
7853
|
+
"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
|
|
7854
|
+
"**/__tests__/**",
|
|
7855
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
|
|
7856
|
+
"**/.{eslint,mocha}rc.{js,cjs}"
|
|
7857
|
+
];
|
|
7858
|
+
function resolveC8Options(options, root) {
|
|
7859
|
+
const resolved = __spreadValues$1({
|
|
7860
|
+
enabled: false,
|
|
7861
|
+
clean: true,
|
|
7862
|
+
cleanOnRerun: false,
|
|
7863
|
+
reportsDirectory: "./coverage",
|
|
7864
|
+
excludeNodeModules: true,
|
|
7865
|
+
exclude: defaultExcludes,
|
|
7866
|
+
reporter: ["text", "html"],
|
|
7867
|
+
allowExternal: false
|
|
7868
|
+
}, options);
|
|
7869
|
+
resolved.reporter = toArray(resolved.reporter);
|
|
7870
|
+
resolved.reportsDirectory = resolve(root, resolved.reportsDirectory);
|
|
7871
|
+
resolved.tempDirectory = process.env.NODE_V8_COVERAGE || resolve(resolved.reportsDirectory, "tmp");
|
|
7872
|
+
return resolved;
|
|
7873
|
+
}
|
|
7874
|
+
async function cleanCoverage(options, clean = true) {
|
|
7875
|
+
if (clean && existsSync(options.reportsDirectory))
|
|
7876
|
+
await promises.rmdir(options.reportsDirectory, { recursive: true });
|
|
7877
|
+
if (!existsSync(options.tempDirectory))
|
|
7878
|
+
await promises.mkdir(options.tempDirectory, { recursive: true });
|
|
7879
|
+
}
|
|
7880
|
+
const require2 = createRequire(import.meta.url);
|
|
7881
|
+
async function reportCoverage(ctx) {
|
|
7882
|
+
const createReport = require2("c8/lib/report");
|
|
7883
|
+
const report = createReport(ctx.config.coverage);
|
|
7884
|
+
await report.getCoverageMapFromAllCoverageFiles();
|
|
7885
|
+
Array.from(ctx.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/")).forEach(([file, map]) => {
|
|
7886
|
+
const url = pathToFileURL(file).href;
|
|
7887
|
+
report.sourceMapCache[url] = {
|
|
7888
|
+
data: __spreadProps$1(__spreadValues$1({}, map), {
|
|
7889
|
+
sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
|
|
7890
|
+
})
|
|
7891
|
+
};
|
|
7892
|
+
});
|
|
7893
|
+
await report.run();
|
|
7894
|
+
}
|
|
7895
|
+
|
|
7823
7896
|
class StateManager {
|
|
7824
7897
|
constructor() {
|
|
7825
|
-
this.filesMap =
|
|
7826
|
-
this.idMap =
|
|
7898
|
+
this.filesMap = /* @__PURE__ */ new Map();
|
|
7899
|
+
this.idMap = /* @__PURE__ */ new Map();
|
|
7827
7900
|
this.taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
7828
7901
|
}
|
|
7829
7902
|
getFiles(keys) {
|
|
7830
7903
|
if (keys)
|
|
7831
|
-
return keys.map((key) => this.filesMap
|
|
7832
|
-
return
|
|
7904
|
+
return keys.map((key) => this.filesMap.get(key));
|
|
7905
|
+
return Array.from(this.filesMap.values());
|
|
7833
7906
|
}
|
|
7834
|
-
collectFiles(files) {
|
|
7907
|
+
collectFiles(files = []) {
|
|
7835
7908
|
files.forEach((file) => {
|
|
7836
|
-
this.filesMap
|
|
7909
|
+
this.filesMap.set(file.filepath, file);
|
|
7837
7910
|
this.updateId(file);
|
|
7838
7911
|
});
|
|
7839
7912
|
}
|
|
7840
7913
|
updateId(task) {
|
|
7841
|
-
if (this.idMap
|
|
7914
|
+
if (this.idMap.get(task.id) === task)
|
|
7842
7915
|
return;
|
|
7843
|
-
this.idMap
|
|
7916
|
+
this.idMap.set(task.id, task);
|
|
7844
7917
|
if (task.type === "suite") {
|
|
7845
7918
|
task.tasks.forEach((task2) => {
|
|
7846
7919
|
this.updateId(task2);
|
|
@@ -7849,38 +7922,39 @@ class StateManager {
|
|
|
7849
7922
|
}
|
|
7850
7923
|
updateTasks(packs) {
|
|
7851
7924
|
for (const [id, result] of packs) {
|
|
7852
|
-
if (this.idMap
|
|
7853
|
-
this.idMap
|
|
7925
|
+
if (this.idMap.has(id))
|
|
7926
|
+
this.idMap.get(id).result = result;
|
|
7854
7927
|
}
|
|
7855
7928
|
}
|
|
7856
7929
|
}
|
|
7857
7930
|
|
|
7858
|
-
var __defProp
|
|
7859
|
-
var __defProps
|
|
7860
|
-
var __getOwnPropDescs
|
|
7861
|
-
var __getOwnPropSymbols
|
|
7862
|
-
var __hasOwnProp
|
|
7863
|
-
var __propIsEnum
|
|
7864
|
-
var __defNormalProp
|
|
7865
|
-
var __spreadValues
|
|
7931
|
+
var __defProp = Object.defineProperty;
|
|
7932
|
+
var __defProps = Object.defineProperties;
|
|
7933
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7934
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7935
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7936
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7937
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7938
|
+
var __spreadValues = (a, b) => {
|
|
7866
7939
|
for (var prop in b || (b = {}))
|
|
7867
|
-
if (__hasOwnProp
|
|
7868
|
-
__defNormalProp
|
|
7869
|
-
if (__getOwnPropSymbols
|
|
7870
|
-
for (var prop of __getOwnPropSymbols
|
|
7871
|
-
if (__propIsEnum
|
|
7872
|
-
__defNormalProp
|
|
7940
|
+
if (__hasOwnProp.call(b, prop))
|
|
7941
|
+
__defNormalProp(a, prop, b[prop]);
|
|
7942
|
+
if (__getOwnPropSymbols)
|
|
7943
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
7944
|
+
if (__propIsEnum.call(b, prop))
|
|
7945
|
+
__defNormalProp(a, prop, b[prop]);
|
|
7873
7946
|
}
|
|
7874
7947
|
return a;
|
|
7875
7948
|
};
|
|
7876
|
-
var __spreadProps
|
|
7949
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7877
7950
|
function resolveConfig(options, viteConfig) {
|
|
7878
7951
|
var _a, _b;
|
|
7879
7952
|
if (options.dom)
|
|
7880
7953
|
options.environment = "happy-dom";
|
|
7881
|
-
const resolved = __spreadProps
|
|
7954
|
+
const resolved = __spreadProps(__spreadValues({}, deepMerge(options, viteConfig.test)), {
|
|
7882
7955
|
root: viteConfig.root
|
|
7883
7956
|
});
|
|
7957
|
+
resolved.coverage = resolveC8Options(resolved.coverage, resolved.root);
|
|
7884
7958
|
resolved.depsInline = [...((_a = resolved.deps) == null ? void 0 : _a.inline) || []];
|
|
7885
7959
|
resolved.depsExternal = [...((_b = resolved.deps) == null ? void 0 : _b.external) || []];
|
|
7886
7960
|
resolved.environment = resolved.environment || "node";
|
|
@@ -7894,6 +7968,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
7894
7968
|
resolved.testTimeout = resolved.testTimeout ?? 5e3;
|
|
7895
7969
|
resolved.hookTimeout = resolved.hookTimeout ?? 1e4;
|
|
7896
7970
|
resolved.isolate = resolved.isolate ?? true;
|
|
7971
|
+
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
7897
7972
|
resolved.watchIgnore = resolved.watchIgnore ?? [/\/node_modules\//, /\/dist\//];
|
|
7898
7973
|
const CI = !!process.env.CI;
|
|
7899
7974
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
@@ -7929,23 +8004,8 @@ async function _transformRequest(ctx, id) {
|
|
|
7929
8004
|
if (result)
|
|
7930
8005
|
result = await ctx.server.ssrTransform(result.code, result.map, id);
|
|
7931
8006
|
}
|
|
7932
|
-
if (result && process.env.NODE_V8_COVERAGE)
|
|
7933
|
-
|
|
7934
|
-
if (result.map)
|
|
7935
|
-
ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
|
|
7936
|
-
}
|
|
7937
|
-
return result;
|
|
7938
|
-
}
|
|
7939
|
-
let SOURCEMAPPING_URL = "sourceMa";
|
|
7940
|
-
SOURCEMAPPING_URL += "ppingURL";
|
|
7941
|
-
async function withInlineSourcemap(result) {
|
|
7942
|
-
const { code, map } = result;
|
|
7943
|
-
if (code.includes(`${SOURCEMAPPING_URL}=`))
|
|
7944
|
-
return result;
|
|
7945
|
-
if (map)
|
|
7946
|
-
result.code = `${code}
|
|
7947
|
-
|
|
7948
|
-
//# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}`;
|
|
8007
|
+
if ((result == null ? void 0 : result.map) && process.env.NODE_V8_COVERAGE)
|
|
8008
|
+
ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
|
|
7949
8009
|
return result;
|
|
7950
8010
|
}
|
|
7951
8011
|
|
|
@@ -8012,7 +8072,8 @@ function createWorkerPool(ctx) {
|
|
|
8012
8072
|
return {
|
|
8013
8073
|
runTests: runWithFiles("run"),
|
|
8014
8074
|
collectTests: runWithFiles("collect"),
|
|
8015
|
-
close: () =>
|
|
8075
|
+
close: async () => {
|
|
8076
|
+
}
|
|
8016
8077
|
};
|
|
8017
8078
|
}
|
|
8018
8079
|
function createChannel(ctx) {
|
|
@@ -8021,32 +8082,34 @@ function createChannel(ctx) {
|
|
|
8021
8082
|
const workerPort = channel.port1;
|
|
8022
8083
|
createBirpc({
|
|
8023
8084
|
functions: {
|
|
8024
|
-
|
|
8085
|
+
onWorkerExit(code) {
|
|
8025
8086
|
process.exit(code || 1);
|
|
8026
8087
|
},
|
|
8027
8088
|
snapshotSaved(snapshot) {
|
|
8028
8089
|
ctx.snapshot.add(snapshot);
|
|
8029
8090
|
},
|
|
8030
|
-
getSourceMap(id, force) {
|
|
8091
|
+
async getSourceMap(id, force) {
|
|
8031
8092
|
if (force) {
|
|
8032
8093
|
const mod = ctx.server.moduleGraph.getModuleById(id);
|
|
8033
8094
|
if (mod)
|
|
8034
8095
|
ctx.server.moduleGraph.invalidateModule(mod);
|
|
8035
8096
|
}
|
|
8036
|
-
|
|
8097
|
+
const r = await transformRequest(ctx, id);
|
|
8098
|
+
return r == null ? void 0 : r.map;
|
|
8037
8099
|
},
|
|
8038
|
-
fetch(id) {
|
|
8039
|
-
|
|
8100
|
+
async fetch(id) {
|
|
8101
|
+
const r = await transformRequest(ctx, id);
|
|
8102
|
+
return r == null ? void 0 : r.code;
|
|
8040
8103
|
},
|
|
8041
8104
|
onCollected(files) {
|
|
8042
8105
|
ctx.state.collectFiles(files);
|
|
8043
|
-
ctx.report("
|
|
8106
|
+
ctx.report("onCollected", files);
|
|
8044
8107
|
},
|
|
8045
|
-
onTaskUpdate(
|
|
8046
|
-
ctx.state.updateTasks(
|
|
8047
|
-
ctx.report("onTaskUpdate",
|
|
8108
|
+
onTaskUpdate(packs) {
|
|
8109
|
+
ctx.state.updateTasks(packs);
|
|
8110
|
+
ctx.report("onTaskUpdate", packs);
|
|
8048
8111
|
},
|
|
8049
|
-
|
|
8112
|
+
onUserLog(msg) {
|
|
8050
8113
|
ctx.report("onUserConsoleLog", msg);
|
|
8051
8114
|
}
|
|
8052
8115
|
},
|
|
@@ -8060,25 +8123,6 @@ function createChannel(ctx) {
|
|
|
8060
8123
|
return { workerPort, port };
|
|
8061
8124
|
}
|
|
8062
8125
|
|
|
8063
|
-
var __defProp = Object.defineProperty;
|
|
8064
|
-
var __defProps = Object.defineProperties;
|
|
8065
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8066
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8067
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8068
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8069
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8070
|
-
var __spreadValues = (a, b) => {
|
|
8071
|
-
for (var prop in b || (b = {}))
|
|
8072
|
-
if (__hasOwnProp.call(b, prop))
|
|
8073
|
-
__defNormalProp(a, prop, b[prop]);
|
|
8074
|
-
if (__getOwnPropSymbols)
|
|
8075
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
8076
|
-
if (__propIsEnum.call(b, prop))
|
|
8077
|
-
__defNormalProp(a, prop, b[prop]);
|
|
8078
|
-
}
|
|
8079
|
-
return a;
|
|
8080
|
-
};
|
|
8081
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
8082
8126
|
const WATCHER_DEBOUNCE = 100;
|
|
8083
8127
|
class Vitest {
|
|
8084
8128
|
constructor() {
|
|
@@ -8087,6 +8131,8 @@ class Vitest {
|
|
|
8087
8131
|
this.state = void 0;
|
|
8088
8132
|
this.snapshot = void 0;
|
|
8089
8133
|
this.reporters = void 0;
|
|
8134
|
+
this.outputStream = process.stdout;
|
|
8135
|
+
this.errorStream = process.stderr;
|
|
8090
8136
|
this.invalidates = /* @__PURE__ */ new Set();
|
|
8091
8137
|
this.changedTests = /* @__PURE__ */ new Set();
|
|
8092
8138
|
this.visitedFilesMap = /* @__PURE__ */ new Map();
|
|
@@ -8096,7 +8142,7 @@ class Vitest {
|
|
|
8096
8142
|
this.unregisterWatcher = noop$1;
|
|
8097
8143
|
this.console = globalThis.console;
|
|
8098
8144
|
}
|
|
8099
|
-
setServer(options, server) {
|
|
8145
|
+
async setServer(options, server) {
|
|
8100
8146
|
var _a, _b;
|
|
8101
8147
|
(_a = this.unregisterWatcher) == null ? void 0 : _a.call(this);
|
|
8102
8148
|
clearTimeout(this._rerunTimer);
|
|
@@ -8113,18 +8159,21 @@ class Vitest {
|
|
|
8113
8159
|
const Reporter = ReportersMap[i];
|
|
8114
8160
|
if (!Reporter)
|
|
8115
8161
|
throw new Error(`Unknown reporter: ${i}`);
|
|
8116
|
-
return new Reporter(
|
|
8162
|
+
return new Reporter();
|
|
8117
8163
|
}
|
|
8118
8164
|
return i;
|
|
8119
8165
|
});
|
|
8120
8166
|
if (!this.reporters.length)
|
|
8121
|
-
this.reporters.push(new DefaultReporter(
|
|
8167
|
+
this.reporters.push(new DefaultReporter());
|
|
8122
8168
|
if (this.config.watch)
|
|
8123
8169
|
this.registerWatcher();
|
|
8124
8170
|
this.runningPromise = void 0;
|
|
8125
8171
|
this._onRestartListeners.forEach((fn) => fn());
|
|
8172
|
+
if (resolved.coverage.enabled)
|
|
8173
|
+
await cleanCoverage(resolved.coverage, resolved.coverage.clean);
|
|
8126
8174
|
}
|
|
8127
8175
|
async start(filters) {
|
|
8176
|
+
this.report("onInit", this);
|
|
8128
8177
|
const files = await this.globTestFiles(filters);
|
|
8129
8178
|
if (!files.length) {
|
|
8130
8179
|
if (this.config.passWithNoTests)
|
|
@@ -8136,7 +8185,8 @@ class Vitest {
|
|
|
8136
8185
|
await this.runFiles(files);
|
|
8137
8186
|
if (this.config.watch)
|
|
8138
8187
|
await this.report("onWatcherStart");
|
|
8139
|
-
|
|
8188
|
+
if (this.config.coverage.enabled)
|
|
8189
|
+
await reportCoverage(this);
|
|
8140
8190
|
}
|
|
8141
8191
|
async runFiles(files) {
|
|
8142
8192
|
await this.runningPromise;
|
|
@@ -8178,9 +8228,14 @@ class Vitest {
|
|
|
8178
8228
|
this.snapshot.clear();
|
|
8179
8229
|
const files = Array.from(this.changedTests);
|
|
8180
8230
|
this.changedTests.clear();
|
|
8231
|
+
this.log("return");
|
|
8232
|
+
if (this.config.coverage.enabled && this.config.coverage.cleanOnRerun)
|
|
8233
|
+
await cleanCoverage(this.config.coverage);
|
|
8181
8234
|
await this.report("onWatcherRerun", files, triggerId);
|
|
8182
8235
|
await this.runFiles(files);
|
|
8183
8236
|
await this.report("onWatcherStart");
|
|
8237
|
+
if (this.config.coverage.enabled)
|
|
8238
|
+
await reportCoverage(this);
|
|
8184
8239
|
}, WATCHER_DEBOUNCE);
|
|
8185
8240
|
}
|
|
8186
8241
|
registerWatcher() {
|
|
@@ -8193,8 +8248,8 @@ class Vitest {
|
|
|
8193
8248
|
const onUnlink = (id) => {
|
|
8194
8249
|
id = slash$1(id);
|
|
8195
8250
|
this.invalidates.add(id);
|
|
8196
|
-
if (
|
|
8197
|
-
|
|
8251
|
+
if (this.state.filesMap.has(id)) {
|
|
8252
|
+
this.state.filesMap.delete(id);
|
|
8198
8253
|
this.changedTests.delete(id);
|
|
8199
8254
|
}
|
|
8200
8255
|
};
|
|
@@ -8223,7 +8278,7 @@ class Vitest {
|
|
|
8223
8278
|
if (!mod)
|
|
8224
8279
|
return;
|
|
8225
8280
|
this.invalidates.add(id);
|
|
8226
|
-
if (
|
|
8281
|
+
if (this.state.filesMap.has(id)) {
|
|
8227
8282
|
this.changedTests.add(id);
|
|
8228
8283
|
return;
|
|
8229
8284
|
}
|
|
@@ -8253,28 +8308,6 @@ class Vitest {
|
|
|
8253
8308
|
files = files.filter((i) => filters.some((f) => i.includes(f)));
|
|
8254
8309
|
return files;
|
|
8255
8310
|
}
|
|
8256
|
-
async writeC8Sourcemap() {
|
|
8257
|
-
const coverageDir = process.env.NODE_V8_COVERAGE;
|
|
8258
|
-
if (!coverageDir)
|
|
8259
|
-
return;
|
|
8260
|
-
const cache = {};
|
|
8261
|
-
const files = Array.from(this.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/"));
|
|
8262
|
-
files.forEach(([file, map]) => {
|
|
8263
|
-
if (!existsSync(file))
|
|
8264
|
-
return;
|
|
8265
|
-
const url = pathToFileURL(file).href;
|
|
8266
|
-
cache[url] = {
|
|
8267
|
-
data: __spreadProps(__spreadValues({}, map), {
|
|
8268
|
-
sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
|
|
8269
|
-
})
|
|
8270
|
-
};
|
|
8271
|
-
});
|
|
8272
|
-
await promises.writeFile(join(coverageDir, "vitest-source-map.json"), JSON.stringify({
|
|
8273
|
-
"result": [],
|
|
8274
|
-
"timestamp": performance.now(),
|
|
8275
|
-
"source-map-cache": cache
|
|
8276
|
-
}), "utf-8");
|
|
8277
|
-
}
|
|
8278
8311
|
isTargetFile(id) {
|
|
8279
8312
|
if (micromatch_1.isMatch(id, this.config.exclude))
|
|
8280
8313
|
return false;
|
|
@@ -8300,10 +8333,10 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8300
8333
|
async configureServer(server2) {
|
|
8301
8334
|
if (haveStarted)
|
|
8302
8335
|
await ctx.report("onServerRestart");
|
|
8303
|
-
ctx.setServer(options, server2);
|
|
8336
|
+
await ctx.setServer(options, server2);
|
|
8304
8337
|
haveStarted = true;
|
|
8305
8338
|
if (options.api)
|
|
8306
|
-
|
|
8339
|
+
(await import('./setup-b87afd31.js')).setup(ctx);
|
|
8307
8340
|
}
|
|
8308
8341
|
},
|
|
8309
8342
|
MocksPlugin()
|
|
@@ -8312,6 +8345,9 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8312
8345
|
open: options.open,
|
|
8313
8346
|
strictPort: true
|
|
8314
8347
|
},
|
|
8348
|
+
build: {
|
|
8349
|
+
sourcemap: true
|
|
8350
|
+
},
|
|
8315
8351
|
optimizeDeps: {
|
|
8316
8352
|
exclude: [
|
|
8317
8353
|
"vitest"
|
|
@@ -8322,6 +8358,8 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8322
8358
|
await server.pluginContainer.buildStart({});
|
|
8323
8359
|
if (options.api === true)
|
|
8324
8360
|
options.api = defaultPort;
|
|
8361
|
+
if (options.open && !options.api)
|
|
8362
|
+
options.api = defaultPort;
|
|
8325
8363
|
if (typeof options.api === "number")
|
|
8326
8364
|
await server.listen(options.api);
|
|
8327
8365
|
return ctx;
|