vitest 0.16.0 → 0.17.0
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/{chunk-api-setup.f43cd039.mjs → chunk-api-setup.5282c6cb.mjs} +3 -3
- package/dist/{chunk-constants.7b9cfc82.mjs → chunk-constants.511c6e9b.mjs} +7 -1
- package/dist/chunk-env-node.dc514f41.mjs +670 -0
- package/dist/{chunk-integrations-globals.d0c363a6.mjs → chunk-integrations-globals.6bb781c7.mjs} +6 -6
- package/dist/{chunk-runtime-chain.7103058b.mjs → chunk-runtime-chain.68f305d0.mjs} +44 -132
- package/dist/{chunk-runtime-mocker.110e3634.mjs → chunk-runtime-mocker.1c207219.mjs} +28 -54
- package/dist/{chunk-utils-source-map.2556cba8.mjs → chunk-utils-source-map.f52527bc.mjs} +8 -22
- package/dist/{chunk-vite-node-externalize.58e10976.mjs → chunk-vite-node-externalize.1efbe319.mjs} +216 -199
- package/dist/{chunk-vite-node-utils.7450fc0c.mjs → chunk-vite-node-utils.4b58ae05.mjs} +13 -1
- package/dist/cli.mjs +9 -9
- package/dist/entry.mjs +6 -6
- package/dist/index.d.ts +130 -4
- package/dist/index.mjs +2 -2
- package/dist/node.d.ts +135 -16
- package/dist/node.mjs +11 -11
- package/dist/{vendor-entry.efeeaa5c.mjs → vendor-entry.2edaf3e0.mjs} +5 -418
- package/dist/worker.mjs +3 -3
- package/package.json +9 -4
- package/dist/chunk-defaults.dc6dc23d.mjs +0 -302
package/dist/{chunk-vite-node-externalize.58e10976.mjs → chunk-vite-node-externalize.1efbe319.mjs}
RENAMED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage, e as envPackageNames } from './chunk-env-node.dc514f41.mjs';
|
|
2
|
+
import { j as join, l as basename, d as dirname, m as resolve, A as AggregateErrorPonyfill, p as picocolors, s as slash$2, o as isAbsolute, q as relative, t as isNode, u as getTests, e as getFullName, v as hasFailed, x as hasFailedSnapshot, y as getSuites, z as safeSetInterval, B as safeClearInterval, f as safeSetTimeout, C as toArray$1, D as normalize, n as noop$1, h as safeClearTimeout, E as deepMerge, F as toNamespacedPath, g as getCallLastIndex, k as notNullish, G as ensurePackageInstalled, H as stdout } from './chunk-utils-global.79a8b1cc.mjs';
|
|
3
|
+
import { loadConfigFromFile, createServer, mergeConfig } from 'vite';
|
|
3
4
|
import path$a from 'path';
|
|
4
5
|
import url, { fileURLToPath, pathToFileURL } from 'url';
|
|
5
6
|
import process$1 from 'process';
|
|
6
7
|
import fs$8, { promises, existsSync, readFileSync } from 'fs';
|
|
7
|
-
import {
|
|
8
|
-
import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.7b9cfc82.mjs';
|
|
8
|
+
import { d as distDir, c as configFiles, a as defaultPort } from './chunk-constants.511c6e9b.mjs';
|
|
9
9
|
import readline from 'readline';
|
|
10
10
|
import require$$0, { cpus, hostname, constants as constants$5 } from 'os';
|
|
11
11
|
import require$$0$1 from 'util';
|
|
12
12
|
import require$$0$2 from 'stream';
|
|
13
13
|
import require$$2 from 'events';
|
|
14
14
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
15
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
15
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.4b58ae05.mjs';
|
|
16
16
|
import createDebug from 'debug';
|
|
17
17
|
import { MessageChannel } from 'worker_threads';
|
|
18
|
-
import { createHash } from 'crypto';
|
|
19
18
|
import { Tinypool } from 'tinypool';
|
|
19
|
+
import { createHash } from 'crypto';
|
|
20
20
|
import { performance } from 'perf_hooks';
|
|
21
|
-
import { c as stripAnsi, d as stringWidth, e as ansiStyles, h as sliceAnsi, i as cliTruncate, b as parseStacktrace, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.
|
|
21
|
+
import { c as stripAnsi, d as stringWidth, e as ansiStyles, h as sliceAnsi, i as cliTruncate, b as parseStacktrace, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.f52527bc.mjs';
|
|
22
22
|
import { o as onetime$1, s as signalExit, m as mergeStream, g as getStream, c as crossSpawn } from './vendor-index.e5dc6622.mjs';
|
|
23
23
|
import { resolveModule } from 'local-pkg';
|
|
24
24
|
import { Buffer } from 'buffer';
|
|
@@ -26,7 +26,7 @@ import childProcess from 'child_process';
|
|
|
26
26
|
import MagicString from './chunk-magic-string.efe26975.mjs';
|
|
27
27
|
import { p as prompts } from './vendor-index.98e769c1.mjs';
|
|
28
28
|
|
|
29
|
-
var version = "0.
|
|
29
|
+
var version = "0.17.0";
|
|
30
30
|
|
|
31
31
|
class EndError extends Error {
|
|
32
32
|
constructor(value) {
|
|
@@ -6820,25 +6820,6 @@ function patchWindowsImportPath(path) {
|
|
|
6820
6820
|
return path;
|
|
6821
6821
|
}
|
|
6822
6822
|
|
|
6823
|
-
var __defProp$6 = Object.defineProperty;
|
|
6824
|
-
var __defProps$5 = Object.defineProperties;
|
|
6825
|
-
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
6826
|
-
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
6827
|
-
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
6828
|
-
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
6829
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6830
|
-
var __spreadValues$6 = (a, b) => {
|
|
6831
|
-
for (var prop in b || (b = {}))
|
|
6832
|
-
if (__hasOwnProp$6.call(b, prop))
|
|
6833
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
6834
|
-
if (__getOwnPropSymbols$6)
|
|
6835
|
-
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
6836
|
-
if (__propIsEnum$6.call(b, prop))
|
|
6837
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
6838
|
-
}
|
|
6839
|
-
return a;
|
|
6840
|
-
};
|
|
6841
|
-
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
6842
6823
|
const debugRequest = createDebug("vite-node:server:request");
|
|
6843
6824
|
const RealDate = Date;
|
|
6844
6825
|
class ViteNodeServer {
|
|
@@ -6872,7 +6853,7 @@ class ViteNodeServer {
|
|
|
6872
6853
|
async fetchModule(id) {
|
|
6873
6854
|
if (!this.fetchPromiseMap.has(id)) {
|
|
6874
6855
|
this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
|
|
6875
|
-
return this.options.sourcemap !== true ?
|
|
6856
|
+
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
6876
6857
|
}).finally(() => {
|
|
6877
6858
|
this.fetchPromiseMap.delete(id);
|
|
6878
6859
|
}));
|
|
@@ -6998,22 +6979,46 @@ function addSnapshotResult(summary, result) {
|
|
|
6998
6979
|
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
6999
6980
|
}
|
|
7000
6981
|
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
6982
|
+
class BaseSequelizer {
|
|
6983
|
+
constructor(ctx) {
|
|
6984
|
+
this.ctx = ctx;
|
|
6985
|
+
}
|
|
6986
|
+
async shard(files) {
|
|
6987
|
+
const { config } = this.ctx;
|
|
6988
|
+
const { index, count } = config.shard;
|
|
6989
|
+
const shardSize = Math.ceil(files.length / count);
|
|
6990
|
+
const shardStart = shardSize * (index - 1);
|
|
6991
|
+
const shardEnd = shardSize * index;
|
|
6992
|
+
return [...files].map((file) => {
|
|
6993
|
+
const fullPath = resolve(slash$1(config.root), slash$1(file));
|
|
6994
|
+
const specPath = fullPath == null ? void 0 : fullPath.slice(config.root.length);
|
|
6995
|
+
return {
|
|
6996
|
+
file,
|
|
6997
|
+
hash: createHash("sha1").update(specPath).digest("hex")
|
|
6998
|
+
};
|
|
6999
|
+
}).sort((a, b) => a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0).slice(shardStart, shardEnd).map(({ file }) => file);
|
|
7000
|
+
}
|
|
7001
|
+
async sort(files) {
|
|
7002
|
+
const { state } = this.ctx;
|
|
7003
|
+
return [...files].sort((a, b) => {
|
|
7004
|
+
const aState = state.getFileTestResults(a);
|
|
7005
|
+
const bState = state.getFileTestResults(b);
|
|
7006
|
+
if (!aState || !bState) {
|
|
7007
|
+
const statsA = state.getFileStats(a);
|
|
7008
|
+
const statsB = state.getFileStats(b);
|
|
7009
|
+
if (!statsA || !statsB)
|
|
7010
|
+
return !statsA && statsB ? -1 : !statsB && statsA ? 1 : 0;
|
|
7011
|
+
return statsB.size - statsA.size;
|
|
7012
|
+
}
|
|
7013
|
+
if (aState.failed && !bState.failed)
|
|
7014
|
+
return -1;
|
|
7015
|
+
if (!aState.failed && bState.failed)
|
|
7016
|
+
return 1;
|
|
7017
|
+
return bState.duration - aState.duration;
|
|
7018
|
+
});
|
|
7019
|
+
}
|
|
7020
|
+
}
|
|
7021
|
+
|
|
7017
7022
|
const workerPath = pathToFileURL(resolve(distDir, "./worker.mjs")).href;
|
|
7018
7023
|
function createPool(ctx) {
|
|
7019
7024
|
var _a;
|
|
@@ -7037,12 +7042,14 @@ function createPool(ctx) {
|
|
|
7037
7042
|
}
|
|
7038
7043
|
if (ctx.config.coverage.enabled)
|
|
7039
7044
|
(_a = process.env).NODE_V8_COVERAGE || (_a.NODE_V8_COVERAGE = ctx.config.coverage.tempDirectory);
|
|
7040
|
-
options.env =
|
|
7045
|
+
options.env = {
|
|
7041
7046
|
TEST: "true",
|
|
7042
7047
|
VITEST: "true",
|
|
7043
7048
|
NODE_ENV: ctx.config.mode || "test",
|
|
7044
|
-
VITEST_MODE: ctx.config.watch ? "WATCH" : "RUN"
|
|
7045
|
-
|
|
7049
|
+
VITEST_MODE: ctx.config.watch ? "WATCH" : "RUN",
|
|
7050
|
+
...process.env,
|
|
7051
|
+
...ctx.config.env
|
|
7052
|
+
};
|
|
7046
7053
|
const pool = new Tinypool(options);
|
|
7047
7054
|
const runWithFiles = (name) => {
|
|
7048
7055
|
let id = 0;
|
|
@@ -7063,22 +7070,12 @@ function createPool(ctx) {
|
|
|
7063
7070
|
workerPort.close();
|
|
7064
7071
|
}
|
|
7065
7072
|
}
|
|
7073
|
+
const sequelizer = new BaseSequelizer(ctx);
|
|
7066
7074
|
return async (files, invalidates) => {
|
|
7067
7075
|
const config = ctx.getSerializableConfig();
|
|
7068
|
-
if (config.shard)
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
const shardStart = shardSize * (index - 1);
|
|
7072
|
-
const shardEnd = shardSize * index;
|
|
7073
|
-
files = files.map((file) => {
|
|
7074
|
-
const fullPath = resolve(slash$2(config.root), slash$2(file));
|
|
7075
|
-
const specPath = fullPath.slice(config.root.length);
|
|
7076
|
-
return {
|
|
7077
|
-
file,
|
|
7078
|
-
hash: createHash("sha1").update(specPath).digest("hex")
|
|
7079
|
-
};
|
|
7080
|
-
}).sort((a, b) => a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0).slice(shardStart, shardEnd).map(({ file }) => file);
|
|
7081
|
-
}
|
|
7076
|
+
if (config.shard)
|
|
7077
|
+
files = await sequelizer.shard(files);
|
|
7078
|
+
files = await sequelizer.sort(files);
|
|
7082
7079
|
if (!ctx.config.threads) {
|
|
7083
7080
|
await runFiles(config, files);
|
|
7084
7081
|
} else {
|
|
@@ -7325,7 +7322,7 @@ class BaseReporter {
|
|
|
7325
7322
|
const mode = this.ctx.config.watch ? picocolors.exports.blue(" DEV ") : picocolors.exports.cyan(" RUN ");
|
|
7326
7323
|
this.ctx.log(`${picocolors.exports.inverse(picocolors.exports.bold(mode))} ${versionTest} ${picocolors.exports.gray(this.ctx.config.root)}`);
|
|
7327
7324
|
if (this.ctx.config.ui)
|
|
7328
|
-
this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_a2 = this.ctx.config.api) == null ? void 0 : _a2.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}`)));
|
|
7325
|
+
this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_a2 = this.ctx.config.api) == null ? void 0 : _a2.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
|
|
7329
7326
|
else if (this.ctx.config.api)
|
|
7330
7327
|
this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.config.api.port}`)}`)));
|
|
7331
7328
|
this.ctx.log();
|
|
@@ -8485,33 +8482,15 @@ class TapReporter {
|
|
|
8485
8482
|
}
|
|
8486
8483
|
}
|
|
8487
8484
|
|
|
8488
|
-
var __defProp$4 = Object.defineProperty;
|
|
8489
|
-
var __defProps$4 = Object.defineProperties;
|
|
8490
|
-
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
8491
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
8492
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
8493
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
8494
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8495
|
-
var __spreadValues$4 = (a, b) => {
|
|
8496
|
-
for (var prop in b || (b = {}))
|
|
8497
|
-
if (__hasOwnProp$4.call(b, prop))
|
|
8498
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
8499
|
-
if (__getOwnPropSymbols$4)
|
|
8500
|
-
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
8501
|
-
if (__propIsEnum$4.call(b, prop))
|
|
8502
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
8503
|
-
}
|
|
8504
|
-
return a;
|
|
8505
|
-
};
|
|
8506
|
-
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
8507
8485
|
function flattenTasks$1(task, baseName = "") {
|
|
8508
8486
|
const base = baseName ? `${baseName} > ` : "";
|
|
8509
8487
|
if (task.type === "suite") {
|
|
8510
8488
|
return task.tasks.flatMap((child) => flattenTasks$1(child, `${base}${task.name}`));
|
|
8511
8489
|
} else {
|
|
8512
|
-
return [
|
|
8490
|
+
return [{
|
|
8491
|
+
...task,
|
|
8513
8492
|
name: `${base}${task.name}`
|
|
8514
|
-
}
|
|
8493
|
+
}];
|
|
8515
8494
|
}
|
|
8516
8495
|
}
|
|
8517
8496
|
function removeInvalidXMLCharacters(value, removeDiscouragedChars) {
|
|
@@ -8627,10 +8606,11 @@ class JUnitReporter {
|
|
|
8627
8606
|
failures: 0,
|
|
8628
8607
|
skipped: 0
|
|
8629
8608
|
});
|
|
8630
|
-
return
|
|
8609
|
+
return {
|
|
8610
|
+
...file,
|
|
8631
8611
|
tasks,
|
|
8632
8612
|
stats
|
|
8633
|
-
}
|
|
8613
|
+
};
|
|
8634
8614
|
});
|
|
8635
8615
|
await this.writeElement("testsuites", {}, async () => {
|
|
8636
8616
|
for (const file of transformed) {
|
|
@@ -8653,33 +8633,15 @@ class JUnitReporter {
|
|
|
8653
8633
|
}
|
|
8654
8634
|
}
|
|
8655
8635
|
|
|
8656
|
-
var __defProp$3 = Object.defineProperty;
|
|
8657
|
-
var __defProps$3 = Object.defineProperties;
|
|
8658
|
-
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
8659
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
8660
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
8661
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
8662
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8663
|
-
var __spreadValues$3 = (a, b) => {
|
|
8664
|
-
for (var prop in b || (b = {}))
|
|
8665
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
8666
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
8667
|
-
if (__getOwnPropSymbols$3)
|
|
8668
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
8669
|
-
if (__propIsEnum$3.call(b, prop))
|
|
8670
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
8671
|
-
}
|
|
8672
|
-
return a;
|
|
8673
|
-
};
|
|
8674
|
-
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
8675
8636
|
function flattenTasks(task, baseName = "") {
|
|
8676
8637
|
const base = baseName ? `${baseName} > ` : "";
|
|
8677
8638
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
8678
8639
|
return task.tasks.flatMap((child) => flattenTasks(child, `${base}${task.name}`));
|
|
8679
8640
|
} else {
|
|
8680
|
-
return [
|
|
8641
|
+
return [{
|
|
8642
|
+
...task,
|
|
8681
8643
|
name: `${base}${task.name}`
|
|
8682
|
-
}
|
|
8644
|
+
}];
|
|
8683
8645
|
}
|
|
8684
8646
|
}
|
|
8685
8647
|
class TapFlatReporter extends TapReporter {
|
|
@@ -8730,12 +8692,95 @@ function createReporters(reporterReferences, runner) {
|
|
|
8730
8692
|
return Promise.all(promisedReporters);
|
|
8731
8693
|
}
|
|
8732
8694
|
|
|
8695
|
+
class FilesStatsCache {
|
|
8696
|
+
constructor() {
|
|
8697
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
8698
|
+
}
|
|
8699
|
+
getStats(fsPath) {
|
|
8700
|
+
return this.cache.get(fsPath);
|
|
8701
|
+
}
|
|
8702
|
+
async updateStats(fsPath) {
|
|
8703
|
+
if (!fs$8.existsSync(fsPath))
|
|
8704
|
+
return;
|
|
8705
|
+
const stats = await fs$8.promises.stat(fsPath);
|
|
8706
|
+
this.cache.set(fsPath, { size: stats.size });
|
|
8707
|
+
}
|
|
8708
|
+
removeStats(fsPath) {
|
|
8709
|
+
this.cache.delete(fsPath);
|
|
8710
|
+
}
|
|
8711
|
+
}
|
|
8712
|
+
|
|
8713
|
+
class ResultsCache {
|
|
8714
|
+
constructor() {
|
|
8715
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
8716
|
+
this.cachePath = null;
|
|
8717
|
+
this.version = version;
|
|
8718
|
+
this.root = "/";
|
|
8719
|
+
}
|
|
8720
|
+
setConfig(root, config) {
|
|
8721
|
+
this.root = root;
|
|
8722
|
+
if (config)
|
|
8723
|
+
this.cachePath = resolve(config.dir, "results.json");
|
|
8724
|
+
}
|
|
8725
|
+
getResults(fsPath) {
|
|
8726
|
+
return this.cache.get(fsPath == null ? void 0 : fsPath.slice(this.root.length));
|
|
8727
|
+
}
|
|
8728
|
+
async readFromCache() {
|
|
8729
|
+
if (!this.cachePath)
|
|
8730
|
+
return;
|
|
8731
|
+
if (fs$8.existsSync(this.cachePath)) {
|
|
8732
|
+
const resultsCache = await fs$8.promises.readFile(this.cachePath, "utf8");
|
|
8733
|
+
const { results, version: version2 } = JSON.parse(resultsCache);
|
|
8734
|
+
this.cache = new Map(results);
|
|
8735
|
+
this.version = version2;
|
|
8736
|
+
}
|
|
8737
|
+
}
|
|
8738
|
+
updateResults(files) {
|
|
8739
|
+
files.forEach((file) => {
|
|
8740
|
+
var _a;
|
|
8741
|
+
const result = file.result;
|
|
8742
|
+
if (!result)
|
|
8743
|
+
return;
|
|
8744
|
+
const duration = result.duration || 0;
|
|
8745
|
+
const relativePath = (_a = file.filepath) == null ? void 0 : _a.slice(this.root.length);
|
|
8746
|
+
this.cache.set(relativePath, {
|
|
8747
|
+
duration: duration >= 0 ? duration : 0,
|
|
8748
|
+
failed: result.state === "fail"
|
|
8749
|
+
});
|
|
8750
|
+
});
|
|
8751
|
+
}
|
|
8752
|
+
removeFromCache(filepath) {
|
|
8753
|
+
this.cache.delete(filepath);
|
|
8754
|
+
}
|
|
8755
|
+
async writeToCache() {
|
|
8756
|
+
if (!this.cachePath)
|
|
8757
|
+
return;
|
|
8758
|
+
const results = Array.from(this.cache.entries());
|
|
8759
|
+
const cacheDirname = dirname(this.cachePath);
|
|
8760
|
+
if (!fs$8.existsSync(cacheDirname))
|
|
8761
|
+
await fs$8.promises.mkdir(cacheDirname, { recursive: true });
|
|
8762
|
+
const cache = JSON.stringify({
|
|
8763
|
+
version: this.version,
|
|
8764
|
+
results
|
|
8765
|
+
});
|
|
8766
|
+
await fs$8.promises.writeFile(this.cachePath, cache);
|
|
8767
|
+
}
|
|
8768
|
+
}
|
|
8769
|
+
|
|
8733
8770
|
class StateManager {
|
|
8734
8771
|
constructor() {
|
|
8735
8772
|
this.filesMap = /* @__PURE__ */ new Map();
|
|
8736
8773
|
this.idMap = /* @__PURE__ */ new Map();
|
|
8737
8774
|
this.taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
8738
8775
|
this.errorsSet = /* @__PURE__ */ new Set();
|
|
8776
|
+
this.results = new ResultsCache();
|
|
8777
|
+
this.stats = new FilesStatsCache();
|
|
8778
|
+
}
|
|
8779
|
+
getFileTestResults(id) {
|
|
8780
|
+
return this.results.getResults(id);
|
|
8781
|
+
}
|
|
8782
|
+
getFileStats(id) {
|
|
8783
|
+
return this.stats.getStats(id);
|
|
8739
8784
|
}
|
|
8740
8785
|
catchError(err, type) {
|
|
8741
8786
|
err.type = type;
|
|
@@ -8749,7 +8794,7 @@ class StateManager {
|
|
|
8749
8794
|
}
|
|
8750
8795
|
getFiles(keys) {
|
|
8751
8796
|
if (keys)
|
|
8752
|
-
return keys.map((key) => this.filesMap.get(key));
|
|
8797
|
+
return keys.map((key) => this.filesMap.get(key)).filter(Boolean);
|
|
8753
8798
|
return Array.from(this.filesMap.values());
|
|
8754
8799
|
}
|
|
8755
8800
|
getFilepaths() {
|
|
@@ -8793,28 +8838,32 @@ class StateManager {
|
|
|
8793
8838
|
}
|
|
8794
8839
|
}
|
|
8795
8840
|
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
var
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8841
|
+
class VitestCache {
|
|
8842
|
+
static resolveCacheDir(root, dir) {
|
|
8843
|
+
return resolve(root, slash$2(dir || "node_modules/.vitest"));
|
|
8844
|
+
}
|
|
8845
|
+
static async clearCache(options) {
|
|
8846
|
+
var _a;
|
|
8847
|
+
const root = resolve(options.root || process.cwd());
|
|
8848
|
+
const configPath = options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
8849
|
+
const config = await loadConfigFromFile({ command: "serve", mode: "test" }, configPath);
|
|
8850
|
+
const cache = (_a = config == null ? void 0 : config.config.test) == null ? void 0 : _a.cache;
|
|
8851
|
+
if (cache === false)
|
|
8852
|
+
throw new Error("Cache is disabled");
|
|
8853
|
+
const cachePath = VitestCache.resolveCacheDir(root, cache == null ? void 0 : cache.dir);
|
|
8854
|
+
let cleared = false;
|
|
8855
|
+
if (fs$8.existsSync(cachePath)) {
|
|
8856
|
+
fs$8.rmSync(cachePath, { recursive: true, force: true });
|
|
8857
|
+
cleared = true;
|
|
8811
8858
|
}
|
|
8812
|
-
|
|
8813
|
-
}
|
|
8814
|
-
|
|
8859
|
+
return { dir: cachePath, cleared };
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
|
|
8815
8863
|
const extraInlineDeps = [
|
|
8816
8864
|
/^(?!.*(?:node_modules)).*\.mjs$/,
|
|
8817
8865
|
/^(?!.*(?:node_modules)).*\.cjs\.js$/,
|
|
8866
|
+
/vite\w*\/dist\/client\/env.mjs/,
|
|
8818
8867
|
/\/vitest\/dist\//,
|
|
8819
8868
|
/vitest-virtual-\w+\/dist/,
|
|
8820
8869
|
/@vitest\/dist/,
|
|
@@ -8837,7 +8886,7 @@ function resolveApiConfig(options) {
|
|
|
8837
8886
|
if (options.api.host)
|
|
8838
8887
|
api.host = options.api.host;
|
|
8839
8888
|
} else {
|
|
8840
|
-
api =
|
|
8889
|
+
api = { ...options.api };
|
|
8841
8890
|
}
|
|
8842
8891
|
}
|
|
8843
8892
|
if (api) {
|
|
@@ -8854,9 +8903,11 @@ function resolveConfig(options, viteConfig) {
|
|
|
8854
8903
|
}
|
|
8855
8904
|
options.environment = "happy-dom";
|
|
8856
8905
|
}
|
|
8857
|
-
const resolved =
|
|
8906
|
+
const resolved = {
|
|
8907
|
+
...configDefaults,
|
|
8908
|
+
...options,
|
|
8858
8909
|
root: viteConfig.root
|
|
8859
|
-
}
|
|
8910
|
+
};
|
|
8860
8911
|
if (viteConfig.base !== "/")
|
|
8861
8912
|
resolved.base = viteConfig.base;
|
|
8862
8913
|
resolved.coverage = resolveC8Options(options.coverage || {}, resolved.root);
|
|
@@ -8874,8 +8925,8 @@ function resolveConfig(options, viteConfig) {
|
|
|
8874
8925
|
}
|
|
8875
8926
|
resolved.deps = resolved.deps || {};
|
|
8876
8927
|
if (resolved.deps.inline !== true) {
|
|
8877
|
-
const ssrOptions = viteConfig.ssr
|
|
8878
|
-
if (ssrOptions.noExternal === true && resolved.deps.inline == null) {
|
|
8928
|
+
const ssrOptions = viteConfig.ssr;
|
|
8929
|
+
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.deps.inline == null) {
|
|
8879
8930
|
resolved.deps.inline = true;
|
|
8880
8931
|
} else {
|
|
8881
8932
|
(_b = resolved.deps).inline ?? (_b.inline = []);
|
|
@@ -8911,6 +8962,9 @@ function resolveConfig(options, viteConfig) {
|
|
|
8911
8962
|
resolved.css ?? (resolved.css = {});
|
|
8912
8963
|
if (typeof resolved.css === "object")
|
|
8913
8964
|
(_c = resolved.css).include ?? (_c.include = [/\.module\./]);
|
|
8965
|
+
resolved.cache ?? (resolved.cache = { dir: "" });
|
|
8966
|
+
if (resolved.cache)
|
|
8967
|
+
resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir);
|
|
8914
8968
|
return resolved;
|
|
8915
8969
|
}
|
|
8916
8970
|
|
|
@@ -10203,25 +10257,6 @@ class VitestGit {
|
|
|
10203
10257
|
}
|
|
10204
10258
|
}
|
|
10205
10259
|
|
|
10206
|
-
var __defProp$1 = Object.defineProperty;
|
|
10207
|
-
var __defProps$1 = Object.defineProperties;
|
|
10208
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
10209
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
10210
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
10211
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
10212
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10213
|
-
var __spreadValues$1 = (a, b) => {
|
|
10214
|
-
for (var prop in b || (b = {}))
|
|
10215
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
10216
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
10217
|
-
if (__getOwnPropSymbols$1)
|
|
10218
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
10219
|
-
if (__propIsEnum$1.call(b, prop))
|
|
10220
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
10221
|
-
}
|
|
10222
|
-
return a;
|
|
10223
|
-
};
|
|
10224
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
10225
10260
|
const WATCHER_DEBOUNCE = 100;
|
|
10226
10261
|
const CLOSE_TIMEOUT = 1e3;
|
|
10227
10262
|
class Vitest {
|
|
@@ -10254,7 +10289,7 @@ class Vitest {
|
|
|
10254
10289
|
this.server = server;
|
|
10255
10290
|
this.config = resolved;
|
|
10256
10291
|
this.state = new StateManager();
|
|
10257
|
-
this.snapshot = new SnapshotManager(
|
|
10292
|
+
this.snapshot = new SnapshotManager({ ...resolved.snapshotOptions });
|
|
10258
10293
|
if (this.config.watch)
|
|
10259
10294
|
this.registerWatcher();
|
|
10260
10295
|
this.vitenode = new ViteNodeServer(server, this.config);
|
|
@@ -10274,15 +10309,19 @@ class Vitest {
|
|
|
10274
10309
|
this._onRestartListeners.forEach((fn) => fn());
|
|
10275
10310
|
if (resolved.coverage.enabled)
|
|
10276
10311
|
await cleanCoverage(resolved.coverage, resolved.coverage.clean);
|
|
10312
|
+
this.state.results.setConfig(resolved.root, resolved.cache);
|
|
10313
|
+
await this.state.results.readFromCache();
|
|
10277
10314
|
}
|
|
10278
10315
|
getSerializableConfig() {
|
|
10279
|
-
return deepMerge(
|
|
10316
|
+
return deepMerge({
|
|
10317
|
+
...this.config,
|
|
10280
10318
|
reporters: [],
|
|
10281
|
-
snapshotOptions:
|
|
10319
|
+
snapshotOptions: {
|
|
10320
|
+
...this.config.snapshotOptions,
|
|
10282
10321
|
resolveSnapshotPath: void 0
|
|
10283
|
-
}
|
|
10322
|
+
},
|
|
10284
10323
|
onConsoleLog: void 0
|
|
10285
|
-
}
|
|
10324
|
+
}, this.configOverride || {});
|
|
10286
10325
|
}
|
|
10287
10326
|
async start(filters) {
|
|
10288
10327
|
await this.report("onInit", this);
|
|
@@ -10302,6 +10341,7 @@ class Vitest {
|
|
|
10302
10341
|
this.error(picocolors.exports.red("\nNo test files found, exiting with code 1"));
|
|
10303
10342
|
process.exit(exitCode);
|
|
10304
10343
|
}
|
|
10344
|
+
await Promise.all(files.map((file) => this.state.stats.updateStats(file)));
|
|
10305
10345
|
await this.runFiles(files);
|
|
10306
10346
|
if (this.config.coverage.enabled)
|
|
10307
10347
|
await reportCoverage(this);
|
|
@@ -10355,7 +10395,7 @@ class Vitest {
|
|
|
10355
10395
|
}
|
|
10356
10396
|
return runningTests;
|
|
10357
10397
|
}
|
|
10358
|
-
async runFiles(
|
|
10398
|
+
async runFiles(paths) {
|
|
10359
10399
|
await this.runningPromise;
|
|
10360
10400
|
this.runningPromise = (async () => {
|
|
10361
10401
|
if (!this.pool)
|
|
@@ -10365,13 +10405,16 @@ class Vitest {
|
|
|
10365
10405
|
this.snapshot.clear();
|
|
10366
10406
|
this.state.clearErrors();
|
|
10367
10407
|
try {
|
|
10368
|
-
await this.pool.runTests(
|
|
10408
|
+
await this.pool.runTests(paths, invalidates);
|
|
10369
10409
|
} catch (err) {
|
|
10370
10410
|
this.state.catchError(err, "Unhandled Error");
|
|
10371
10411
|
}
|
|
10372
|
-
|
|
10412
|
+
const files = this.state.getFiles();
|
|
10413
|
+
if (hasFailed(files))
|
|
10373
10414
|
process.exitCode = 1;
|
|
10374
|
-
await this.report("onFinished",
|
|
10415
|
+
await this.report("onFinished", files, this.state.getUnhandledErrors());
|
|
10416
|
+
this.state.results.updateResults(files);
|
|
10417
|
+
await this.state.results.writeToCache();
|
|
10375
10418
|
})().finally(() => {
|
|
10376
10419
|
this.runningPromise = void 0;
|
|
10377
10420
|
});
|
|
@@ -10460,6 +10503,8 @@ class Vitest {
|
|
|
10460
10503
|
this.invalidates.add(id);
|
|
10461
10504
|
if (this.state.filesMap.has(id)) {
|
|
10462
10505
|
this.state.filesMap.delete(id);
|
|
10506
|
+
this.state.results.removeFromCache(id);
|
|
10507
|
+
this.state.stats.removeStats(id);
|
|
10463
10508
|
this.changedTests.delete(id);
|
|
10464
10509
|
this.report("onTestRemoved", id);
|
|
10465
10510
|
}
|
|
@@ -10468,6 +10513,7 @@ class Vitest {
|
|
|
10468
10513
|
id = slash$2(id);
|
|
10469
10514
|
if (await this.isTargetFile(id)) {
|
|
10470
10515
|
this.changedTests.add(id);
|
|
10516
|
+
await this.state.stats.updateStats(id);
|
|
10471
10517
|
this.scheduleRerun(id);
|
|
10472
10518
|
}
|
|
10473
10519
|
};
|
|
@@ -10823,37 +10869,6 @@ function CSSEnablerPlugin(ctx) {
|
|
|
10823
10869
|
};
|
|
10824
10870
|
}
|
|
10825
10871
|
|
|
10826
|
-
var __defProp = Object.defineProperty;
|
|
10827
|
-
var __defProps = Object.defineProperties;
|
|
10828
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10829
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10830
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10831
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10832
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10833
|
-
var __spreadValues = (a, b) => {
|
|
10834
|
-
for (var prop in b || (b = {}))
|
|
10835
|
-
if (__hasOwnProp.call(b, prop))
|
|
10836
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10837
|
-
if (__getOwnPropSymbols)
|
|
10838
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
10839
|
-
if (__propIsEnum.call(b, prop))
|
|
10840
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10841
|
-
}
|
|
10842
|
-
return a;
|
|
10843
|
-
};
|
|
10844
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
10845
|
-
var __objRest = (source, exclude) => {
|
|
10846
|
-
var target = {};
|
|
10847
|
-
for (var prop in source)
|
|
10848
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
10849
|
-
target[prop] = source[prop];
|
|
10850
|
-
if (source != null && __getOwnPropSymbols)
|
|
10851
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
10852
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
10853
|
-
target[prop] = source[prop];
|
|
10854
|
-
}
|
|
10855
|
-
return target;
|
|
10856
|
-
};
|
|
10857
10872
|
async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
10858
10873
|
let haveStarted = false;
|
|
10859
10874
|
async function UIPlugin() {
|
|
@@ -10899,14 +10914,15 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10899
10914
|
resolve: {
|
|
10900
10915
|
mainFields: []
|
|
10901
10916
|
},
|
|
10902
|
-
server:
|
|
10917
|
+
server: {
|
|
10918
|
+
...preOptions.api,
|
|
10903
10919
|
watch: {
|
|
10904
10920
|
ignored: preOptions.watchExclude
|
|
10905
10921
|
},
|
|
10906
10922
|
open,
|
|
10907
10923
|
hmr: false,
|
|
10908
10924
|
preTransformRequests: false
|
|
10909
|
-
}
|
|
10925
|
+
},
|
|
10910
10926
|
cacheDir: void 0,
|
|
10911
10927
|
optimizeDeps: {
|
|
10912
10928
|
disabled: true,
|
|
@@ -10916,18 +10932,18 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10916
10932
|
return config;
|
|
10917
10933
|
},
|
|
10918
10934
|
async configResolved(viteConfig) {
|
|
10919
|
-
var _b, _c, _d
|
|
10935
|
+
var _a, _b, _c, _d;
|
|
10920
10936
|
const viteConfigTest = viteConfig.test || {};
|
|
10921
10937
|
if (viteConfigTest.watch === false)
|
|
10922
10938
|
viteConfigTest.run = true;
|
|
10923
10939
|
options = deepMerge({}, configDefaults, viteConfigTest, options);
|
|
10924
10940
|
options.api = resolveApiConfig(options);
|
|
10925
|
-
const
|
|
10926
|
-
(
|
|
10927
|
-
(
|
|
10928
|
-
(
|
|
10941
|
+
const { PROD, DEV, ...envs } = viteConfig.env;
|
|
10942
|
+
(_a = process.env).PROD ?? (_a.PROD = PROD ? "1" : "");
|
|
10943
|
+
(_b = process.env).DEV ?? (_b.DEV = DEV ? "1" : "");
|
|
10944
|
+
(_c = process.env).SSR ?? (_c.SSR = "1");
|
|
10929
10945
|
for (const name in envs)
|
|
10930
|
-
(
|
|
10946
|
+
(_d = process.env)[name] ?? (_d[name] = envs[name]);
|
|
10931
10947
|
},
|
|
10932
10948
|
async configureServer(server) {
|
|
10933
10949
|
if (haveStarted)
|
|
@@ -10936,7 +10952,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10936
10952
|
await ctx.setServer(options, server);
|
|
10937
10953
|
haveStarted = true;
|
|
10938
10954
|
if (options.api && options.watch)
|
|
10939
|
-
(await import('./chunk-api-setup.
|
|
10955
|
+
(await import('./chunk-api-setup.5282c6cb.mjs')).setup(ctx);
|
|
10940
10956
|
} catch (err) {
|
|
10941
10957
|
ctx.printError(err, true);
|
|
10942
10958
|
process.exit(1);
|
|
@@ -11059,7 +11075,8 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
11059
11075
|
}
|
|
11060
11076
|
}
|
|
11061
11077
|
if (ctx.config.environment && ctx.config.environment !== "node") {
|
|
11062
|
-
|
|
11078
|
+
const packageName = envPackageNames[ctx.config.environment];
|
|
11079
|
+
if (!await ensurePackageInstalled(packageName)) {
|
|
11063
11080
|
process.exitCode = 1;
|
|
11064
11081
|
return false;
|
|
11065
11082
|
}
|