vitest 0.8.3 → 0.9.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.175eacf7.js → chunk-api-setup.e8071f5b.js} +4 -4
- package/dist/{chunk-constants.6062c404.js → chunk-constants.596ee4d5.js} +1 -1
- package/dist/{chunk-defaults.e5535971.js → chunk-defaults.731639a8.js} +4 -3
- package/dist/chunk-integrations-globals.d1145578.js +23 -0
- package/dist/{chunk-runtime-chain.766f27fd.js → chunk-runtime-chain.a5280da7.js} +232 -171
- package/dist/{chunk-runtime-mocker.def94aba.js → chunk-runtime-mocker.ff55be7d.js} +32 -35
- package/dist/chunk-runtime-rpc.3f693817.js +7 -0
- package/dist/{chunk-utils-base.8408f73a.js → chunk-utils-global.35d3b35d.js} +18 -1
- package/dist/{chunk-utils-timers.7bdeea22.js → chunk-utils-timers.73950dcb.js} +13 -10
- package/dist/{chunk-vite-node-externalize.ecc58a1f.js → chunk-vite-node-externalize.2004587d.js} +233 -76
- package/dist/{chunk-vite-node-utils.3c7ce184.js → chunk-vite-node-utils.5fa30ee7.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/config.cjs +3 -2
- package/dist/config.d.ts +26 -2
- package/dist/config.js +3 -2
- package/dist/entry.js +85 -53
- package/dist/index.d.ts +29 -10
- package/dist/index.js +5 -6
- package/dist/node.d.ts +21 -4
- package/dist/node.js +7 -8
- package/dist/{jest-mock.js → spy.js} +3 -0
- package/dist/worker.js +5 -6
- package/package.json +16 -16
- package/dist/chunk-integrations-globals.ade0c248.js +0 -24
- package/dist/chunk-runtime-rpc.e8aa1ebe.js +0 -8
- package/dist/chunk-utils-global.7bcfa03c.js +0 -5
package/dist/{chunk-vite-node-externalize.ecc58a1f.js → chunk-vite-node-externalize.2004587d.js}
RENAMED
|
@@ -5,17 +5,17 @@ import process$2 from 'process';
|
|
|
5
5
|
import { o as onExit, m as mergeStream, g as getStream, c as crossSpawn, a as onetime$1 } from './vendor-index.87b2fc14.js';
|
|
6
6
|
import url, { fileURLToPath, pathToFileURL } from 'url';
|
|
7
7
|
import require$$0, { constants as constants$8, hostname, cpus } from 'os';
|
|
8
|
-
import { j as join, d as c, s as slash$2,
|
|
8
|
+
import { j as join, h as basename, k as dirname, d as c, s as slash$2, l as isAbsolute, m as relative, o as getTests, p as getFullName, q as hasFailed, u as hasFailedSnapshot, v as getSuites, w as resolve, t as toArray, n as noop$1, x as deepMerge, y as toNamespacedPath, b as getCallLastIndex, f as notNullish, z as ensurePackageInstalled } from './chunk-utils-global.35d3b35d.js';
|
|
9
9
|
import { createServer, mergeConfig } from 'vite';
|
|
10
10
|
import fs$8, { promises, existsSync } from 'fs';
|
|
11
|
-
import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.
|
|
11
|
+
import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.596ee4d5.js';
|
|
12
12
|
import require$$0$1 from 'util';
|
|
13
13
|
import require$$0$2 from 'stream';
|
|
14
14
|
import require$$2 from 'events';
|
|
15
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
16
|
-
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.
|
|
15
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.5fa30ee7.js';
|
|
16
|
+
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.731639a8.js';
|
|
17
17
|
import { performance } from 'perf_hooks';
|
|
18
|
-
import { b as stripAnsi, d as stringWidth, e as ansiStyles, f as sliceAnsi, h as setInterval, i as clearInterval, j as cliTruncate, s as setTimeout$1, a as parseStacktrace, k as interpretSourcePos, u as unifiedDiff, p as posToNumber, l as lineSplitRE, c as clearTimeout$1 } from './chunk-utils-timers.
|
|
18
|
+
import { b as stripAnsi, d as stringWidth, e as ansiStyles, f as sliceAnsi, h as setInterval, i as clearInterval, j as cliTruncate, s as setTimeout$1, a as parseStacktrace, k as interpretSourcePos, u as unifiedDiff, p as posToNumber, l as lineSplitRE, c as clearTimeout$1 } from './chunk-utils-timers.73950dcb.js';
|
|
19
19
|
import { a as commonjsGlobal } from './vendor-_commonjsHelpers.34b404ce.js';
|
|
20
20
|
import assert$1 from 'assert';
|
|
21
21
|
import { MessageChannel } from 'worker_threads';
|
|
@@ -24,7 +24,7 @@ import MagicString from './chunk-magic-string.d5e0e473.js';
|
|
|
24
24
|
import require$$0$3 from 'readline';
|
|
25
25
|
import { p as prompts } from './vendor-index.ee829ed6.js';
|
|
26
26
|
|
|
27
|
-
var version = "0.
|
|
27
|
+
var version = "0.9.0";
|
|
28
28
|
|
|
29
29
|
function stripFinalNewline(input) {
|
|
30
30
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
@@ -10351,9 +10351,7 @@ const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
|
10351
10351
|
const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/;
|
|
10352
10352
|
const defaultInline = [
|
|
10353
10353
|
/virtual:/,
|
|
10354
|
-
/\.ts
|
|
10355
|
-
ESM_EXT_RE,
|
|
10356
|
-
ESM_FOLDER_RE
|
|
10354
|
+
/\.ts$/
|
|
10357
10355
|
];
|
|
10358
10356
|
const depsExternal = [
|
|
10359
10357
|
/\.cjs\.js$/,
|
|
@@ -10432,21 +10430,21 @@ function patchWindowsImportPath(path) {
|
|
|
10432
10430
|
return path;
|
|
10433
10431
|
}
|
|
10434
10432
|
|
|
10435
|
-
var __defProp$
|
|
10433
|
+
var __defProp$5 = Object.defineProperty;
|
|
10436
10434
|
var __defProps$4 = Object.defineProperties;
|
|
10437
10435
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
10438
|
-
var __getOwnPropSymbols$
|
|
10439
|
-
var __hasOwnProp$
|
|
10440
|
-
var __propIsEnum$
|
|
10441
|
-
var __defNormalProp$
|
|
10442
|
-
var __spreadValues$
|
|
10436
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
10437
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
10438
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
10439
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10440
|
+
var __spreadValues$5 = (a, b) => {
|
|
10443
10441
|
for (var prop in b || (b = {}))
|
|
10444
|
-
if (__hasOwnProp$
|
|
10445
|
-
__defNormalProp$
|
|
10446
|
-
if (__getOwnPropSymbols$
|
|
10447
|
-
for (var prop of __getOwnPropSymbols$
|
|
10448
|
-
if (__propIsEnum$
|
|
10449
|
-
__defNormalProp$
|
|
10442
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
10443
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
10444
|
+
if (__getOwnPropSymbols$5)
|
|
10445
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
10446
|
+
if (__propIsEnum$5.call(b, prop))
|
|
10447
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
10450
10448
|
}
|
|
10451
10449
|
return a;
|
|
10452
10450
|
};
|
|
@@ -10471,7 +10469,7 @@ class ViteNodeServer {
|
|
|
10471
10469
|
async fetchModule(id) {
|
|
10472
10470
|
if (!this.fetchPromiseMap.has(id)) {
|
|
10473
10471
|
this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
|
|
10474
|
-
return this.options.sourcemap !== true ? __spreadProps$4(__spreadValues$
|
|
10472
|
+
return this.options.sourcemap !== true ? __spreadProps$4(__spreadValues$5({}, r), { map: void 0 }) : r;
|
|
10475
10473
|
}).finally(() => {
|
|
10476
10474
|
this.fetchPromiseMap.delete(id);
|
|
10477
10475
|
}));
|
|
@@ -10535,17 +10533,24 @@ class ViteNodeServer {
|
|
|
10535
10533
|
}
|
|
10536
10534
|
|
|
10537
10535
|
class SnapshotManager {
|
|
10538
|
-
constructor(
|
|
10539
|
-
this.
|
|
10536
|
+
constructor(options) {
|
|
10537
|
+
this.options = options;
|
|
10540
10538
|
this.summary = void 0;
|
|
10539
|
+
this.extension = ".snap";
|
|
10541
10540
|
this.clear();
|
|
10542
10541
|
}
|
|
10543
10542
|
clear() {
|
|
10544
|
-
this.summary = emptySummary(this.
|
|
10543
|
+
this.summary = emptySummary(this.options);
|
|
10545
10544
|
}
|
|
10546
10545
|
add(result) {
|
|
10547
10546
|
addSnapshotResult(this.summary, result);
|
|
10548
10547
|
}
|
|
10548
|
+
resolvePath(testPath) {
|
|
10549
|
+
const resolver = this.options.resolveSnapshotPath || (() => {
|
|
10550
|
+
return join(join(dirname(testPath), "__snapshots__"), `${basename(testPath)}${this.extension}`);
|
|
10551
|
+
});
|
|
10552
|
+
return resolver(testPath, this.extension);
|
|
10553
|
+
}
|
|
10549
10554
|
}
|
|
10550
10555
|
function emptySummary(options) {
|
|
10551
10556
|
const summary = {
|
|
@@ -10777,10 +10782,26 @@ class BaseReporter {
|
|
|
10777
10782
|
return;
|
|
10778
10783
|
for (const pack of packs) {
|
|
10779
10784
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
10780
|
-
if (task &&
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10785
|
+
if (task && "filepath" in task && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
10786
|
+
const tests = getTests(task);
|
|
10787
|
+
const failed = tests.filter((t) => {
|
|
10788
|
+
var _a2;
|
|
10789
|
+
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
10790
|
+
});
|
|
10791
|
+
const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
|
|
10792
|
+
let state = c.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
|
|
10793
|
+
if (failed.length)
|
|
10794
|
+
state += ` ${c.dim("|")} ${c.red(`${failed.length} failed`)}`;
|
|
10795
|
+
if (skipped.length)
|
|
10796
|
+
state += ` ${c.dim("|")} ${c.yellow(`${skipped.length} skipped`)}`;
|
|
10797
|
+
let suffix = c.dim(" (") + state + c.dim(")");
|
|
10798
|
+
if (task.result.duration)
|
|
10799
|
+
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
10800
|
+
this.ctx.log(` ${getStateSymbol(task)} ${task.name} ${suffix}`);
|
|
10801
|
+
for (const test of failed) {
|
|
10802
|
+
this.ctx.log(c.red(` ${pointer} ${getFullName(test)}`));
|
|
10803
|
+
this.ctx.log(c.red(` ${F_RIGHT} ${(_c = test.result.error) == null ? void 0 : _c.message}`));
|
|
10804
|
+
}
|
|
10784
10805
|
}
|
|
10785
10806
|
}
|
|
10786
10807
|
}
|
|
@@ -11753,6 +11774,17 @@ class DefaultReporter extends BaseReporter {
|
|
|
11753
11774
|
super(...arguments);
|
|
11754
11775
|
this.rendererOptions = {};
|
|
11755
11776
|
}
|
|
11777
|
+
async onTestRemoved(trigger) {
|
|
11778
|
+
await this.stopListRender();
|
|
11779
|
+
this.ctx.console.clear();
|
|
11780
|
+
this.ctx.log(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
11781
|
+
`) : ""));
|
|
11782
|
+
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
11783
|
+
createListRenderer(files, this.rendererOptions).stop();
|
|
11784
|
+
this.ctx.log();
|
|
11785
|
+
await super.reportSummary(files);
|
|
11786
|
+
super.onWatcherStart();
|
|
11787
|
+
}
|
|
11756
11788
|
onCollected() {
|
|
11757
11789
|
if (this.isTTY) {
|
|
11758
11790
|
this.rendererOptions.outputStream = this.ctx.outputStream;
|
|
@@ -12008,6 +12040,19 @@ class VerboseReporter extends DefaultReporter {
|
|
|
12008
12040
|
super();
|
|
12009
12041
|
this.rendererOptions.renderSucceed = true;
|
|
12010
12042
|
}
|
|
12043
|
+
onTaskUpdate(packs) {
|
|
12044
|
+
var _a, _b, _c;
|
|
12045
|
+
if (this.isTTY)
|
|
12046
|
+
return;
|
|
12047
|
+
for (const pack of packs) {
|
|
12048
|
+
const task = this.ctx.state.idMap.get(pack[0]);
|
|
12049
|
+
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
12050
|
+
this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
|
|
12051
|
+
if (task.result.state === "fail")
|
|
12052
|
+
this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
12053
|
+
}
|
|
12054
|
+
}
|
|
12055
|
+
}
|
|
12011
12056
|
}
|
|
12012
12057
|
|
|
12013
12058
|
class IndentedLogger {
|
|
@@ -12098,21 +12143,21 @@ class TapReporter {
|
|
|
12098
12143
|
}
|
|
12099
12144
|
}
|
|
12100
12145
|
|
|
12101
|
-
var __defProp$
|
|
12146
|
+
var __defProp$4 = Object.defineProperty;
|
|
12102
12147
|
var __defProps$3 = Object.defineProperties;
|
|
12103
12148
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
12104
|
-
var __getOwnPropSymbols$
|
|
12105
|
-
var __hasOwnProp$
|
|
12106
|
-
var __propIsEnum$
|
|
12107
|
-
var __defNormalProp$
|
|
12108
|
-
var __spreadValues$
|
|
12149
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
12150
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
12151
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
12152
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12153
|
+
var __spreadValues$4 = (a, b) => {
|
|
12109
12154
|
for (var prop in b || (b = {}))
|
|
12110
|
-
if (__hasOwnProp$
|
|
12111
|
-
__defNormalProp$
|
|
12112
|
-
if (__getOwnPropSymbols$
|
|
12113
|
-
for (var prop of __getOwnPropSymbols$
|
|
12114
|
-
if (__propIsEnum$
|
|
12115
|
-
__defNormalProp$
|
|
12155
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
12156
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
12157
|
+
if (__getOwnPropSymbols$4)
|
|
12158
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
12159
|
+
if (__propIsEnum$4.call(b, prop))
|
|
12160
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
12116
12161
|
}
|
|
12117
12162
|
return a;
|
|
12118
12163
|
};
|
|
@@ -12122,7 +12167,7 @@ function flattenTasks$1(task, baseName = "") {
|
|
|
12122
12167
|
if (task.type === "suite") {
|
|
12123
12168
|
return task.tasks.flatMap((child) => flattenTasks$1(child, `${base}${task.name}`));
|
|
12124
12169
|
} else {
|
|
12125
|
-
return [__spreadProps$3(__spreadValues$
|
|
12170
|
+
return [__spreadProps$3(__spreadValues$4({}, task), {
|
|
12126
12171
|
name: `${base}${task.name}`
|
|
12127
12172
|
})];
|
|
12128
12173
|
}
|
|
@@ -12230,7 +12275,7 @@ class JUnitReporter {
|
|
|
12230
12275
|
failures: 0,
|
|
12231
12276
|
skipped: 0
|
|
12232
12277
|
});
|
|
12233
|
-
return __spreadProps$3(__spreadValues$
|
|
12278
|
+
return __spreadProps$3(__spreadValues$4({}, file), {
|
|
12234
12279
|
tasks,
|
|
12235
12280
|
stats
|
|
12236
12281
|
});
|
|
@@ -12256,21 +12301,21 @@ class JUnitReporter {
|
|
|
12256
12301
|
}
|
|
12257
12302
|
}
|
|
12258
12303
|
|
|
12259
|
-
var __defProp$
|
|
12304
|
+
var __defProp$3 = Object.defineProperty;
|
|
12260
12305
|
var __defProps$2 = Object.defineProperties;
|
|
12261
12306
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
12262
|
-
var __getOwnPropSymbols$
|
|
12263
|
-
var __hasOwnProp$
|
|
12264
|
-
var __propIsEnum$
|
|
12265
|
-
var __defNormalProp$
|
|
12266
|
-
var __spreadValues$
|
|
12307
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
12308
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
12309
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
12310
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12311
|
+
var __spreadValues$3 = (a, b) => {
|
|
12267
12312
|
for (var prop in b || (b = {}))
|
|
12268
|
-
if (__hasOwnProp$
|
|
12269
|
-
__defNormalProp$
|
|
12270
|
-
if (__getOwnPropSymbols$
|
|
12271
|
-
for (var prop of __getOwnPropSymbols$
|
|
12272
|
-
if (__propIsEnum$
|
|
12273
|
-
__defNormalProp$
|
|
12313
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
12314
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
12315
|
+
if (__getOwnPropSymbols$3)
|
|
12316
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
12317
|
+
if (__propIsEnum$3.call(b, prop))
|
|
12318
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
12274
12319
|
}
|
|
12275
12320
|
return a;
|
|
12276
12321
|
};
|
|
@@ -12280,7 +12325,7 @@ function flattenTasks(task, baseName = "") {
|
|
|
12280
12325
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
12281
12326
|
return task.tasks.flatMap((child) => flattenTasks(child, `${base}${task.name}`));
|
|
12282
12327
|
} else {
|
|
12283
|
-
return [__spreadProps$2(__spreadValues$
|
|
12328
|
+
return [__spreadProps$2(__spreadValues$3({}, task), {
|
|
12284
12329
|
name: `${base}${task.name}`
|
|
12285
12330
|
})];
|
|
12286
12331
|
}
|
|
@@ -12386,6 +12431,9 @@ function createChannel(ctx) {
|
|
|
12386
12431
|
snapshotSaved(snapshot) {
|
|
12387
12432
|
ctx.snapshot.add(snapshot);
|
|
12388
12433
|
},
|
|
12434
|
+
resolveSnapshotPath(testPath) {
|
|
12435
|
+
return ctx.snapshot.resolvePath(testPath);
|
|
12436
|
+
},
|
|
12389
12437
|
async getSourceMap(id, force) {
|
|
12390
12438
|
if (force) {
|
|
12391
12439
|
const mod = ctx.server.moduleGraph.getModuleById(id);
|
|
@@ -12479,21 +12527,21 @@ class StateManager {
|
|
|
12479
12527
|
}
|
|
12480
12528
|
}
|
|
12481
12529
|
|
|
12482
|
-
var __defProp$
|
|
12530
|
+
var __defProp$2 = Object.defineProperty;
|
|
12483
12531
|
var __defProps$1 = Object.defineProperties;
|
|
12484
12532
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
12485
|
-
var __getOwnPropSymbols$
|
|
12486
|
-
var __hasOwnProp$
|
|
12487
|
-
var __propIsEnum$
|
|
12488
|
-
var __defNormalProp$
|
|
12489
|
-
var __spreadValues$
|
|
12533
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
12534
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
12535
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
12536
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12537
|
+
var __spreadValues$2 = (a, b) => {
|
|
12490
12538
|
for (var prop in b || (b = {}))
|
|
12491
|
-
if (__hasOwnProp$
|
|
12492
|
-
__defNormalProp$
|
|
12493
|
-
if (__getOwnPropSymbols$
|
|
12494
|
-
for (var prop of __getOwnPropSymbols$
|
|
12495
|
-
if (__propIsEnum$
|
|
12496
|
-
__defNormalProp$
|
|
12539
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
12540
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
12541
|
+
if (__getOwnPropSymbols$2)
|
|
12542
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
12543
|
+
if (__propIsEnum$2.call(b, prop))
|
|
12544
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
12497
12545
|
}
|
|
12498
12546
|
return a;
|
|
12499
12547
|
};
|
|
@@ -12523,7 +12571,7 @@ function resolveApiConfig(options) {
|
|
|
12523
12571
|
if (options.api.host)
|
|
12524
12572
|
api.host = options.api.host;
|
|
12525
12573
|
} else {
|
|
12526
|
-
api = __spreadValues$
|
|
12574
|
+
api = __spreadValues$2({}, options.api);
|
|
12527
12575
|
}
|
|
12528
12576
|
}
|
|
12529
12577
|
if (api) {
|
|
@@ -12540,7 +12588,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
12540
12588
|
}
|
|
12541
12589
|
options.environment = "happy-dom";
|
|
12542
12590
|
}
|
|
12543
|
-
const resolved = __spreadProps$1(__spreadValues$
|
|
12591
|
+
const resolved = __spreadProps$1(__spreadValues$2(__spreadValues$2({}, configDefaults), options), {
|
|
12544
12592
|
root: viteConfig.root
|
|
12545
12593
|
});
|
|
12546
12594
|
if (viteConfig.base !== "/")
|
|
@@ -12554,8 +12602,11 @@ function resolveConfig(options, viteConfig) {
|
|
|
12554
12602
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
12555
12603
|
resolved.snapshotOptions = {
|
|
12556
12604
|
snapshotFormat: resolved.snapshotFormat || {},
|
|
12557
|
-
updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new"
|
|
12605
|
+
updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
|
|
12606
|
+
resolveSnapshotPath: options.resolveSnapshotPath
|
|
12558
12607
|
};
|
|
12608
|
+
if (options.resolveSnapshotPath)
|
|
12609
|
+
delete resolved.resolveSnapshotPath;
|
|
12559
12610
|
if (process.env.VITEST_MAX_THREADS)
|
|
12560
12611
|
resolved.maxThreads = parseInt(process.env.VITEST_MAX_THREADS);
|
|
12561
12612
|
if (process.env.VITEST_MIN_THREADS)
|
|
@@ -12570,6 +12621,8 @@ function resolveConfig(options, viteConfig) {
|
|
|
12570
12621
|
])).filter(Boolean);
|
|
12571
12622
|
if (!resolved.reporters.length)
|
|
12572
12623
|
resolved.reporters.push("default");
|
|
12624
|
+
if (resolved.changed)
|
|
12625
|
+
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
12573
12626
|
return resolved;
|
|
12574
12627
|
}
|
|
12575
12628
|
|
|
@@ -12630,7 +12683,7 @@ As a temporary workaround you can try to inline the package by updating your con
|
|
|
12630
12683
|
`)));
|
|
12631
12684
|
}
|
|
12632
12685
|
function displayDiff(actual, expected, console, outputTruncateLength) {
|
|
12633
|
-
console.error(c.gray(unifiedDiff(actual, expected, outputTruncateLength)) + "\n");
|
|
12686
|
+
console.error(c.gray(unifiedDiff(actual, expected, { outputTruncateLength })) + "\n");
|
|
12634
12687
|
}
|
|
12635
12688
|
function printErrorMessage(error, console) {
|
|
12636
12689
|
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
@@ -12691,6 +12744,81 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
|
12691
12744
|
return res.join("\n");
|
|
12692
12745
|
}
|
|
12693
12746
|
|
|
12747
|
+
class VitestGit {
|
|
12748
|
+
constructor(cwd) {
|
|
12749
|
+
this.cwd = cwd;
|
|
12750
|
+
}
|
|
12751
|
+
async resolveFilesWithGitCommand(args) {
|
|
12752
|
+
let result;
|
|
12753
|
+
try {
|
|
12754
|
+
result = await execa("git", args, { cwd: this.root });
|
|
12755
|
+
} catch (e) {
|
|
12756
|
+
e.message = e.stderr;
|
|
12757
|
+
throw e;
|
|
12758
|
+
}
|
|
12759
|
+
return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
|
|
12760
|
+
}
|
|
12761
|
+
async findChangedFiles(options) {
|
|
12762
|
+
const root = await this.getRoot(this.cwd);
|
|
12763
|
+
if (!root)
|
|
12764
|
+
return null;
|
|
12765
|
+
this.root = root;
|
|
12766
|
+
const changedSince = options.changedSince;
|
|
12767
|
+
if (typeof changedSince === "string") {
|
|
12768
|
+
const [committed, staged2, unstaged2] = await Promise.all([
|
|
12769
|
+
this.getFilesSince(changedSince),
|
|
12770
|
+
this.getStagedFiles(),
|
|
12771
|
+
this.getUnstagedFiles()
|
|
12772
|
+
]);
|
|
12773
|
+
return [...committed, ...staged2, ...unstaged2];
|
|
12774
|
+
}
|
|
12775
|
+
const [staged, unstaged] = await Promise.all([
|
|
12776
|
+
this.getStagedFiles(),
|
|
12777
|
+
this.getUnstagedFiles()
|
|
12778
|
+
]);
|
|
12779
|
+
return [...staged, ...unstaged];
|
|
12780
|
+
}
|
|
12781
|
+
getFilesSince(hash) {
|
|
12782
|
+
return this.resolveFilesWithGitCommand(["diff", "--name-only", `${hash}...HEAD`]);
|
|
12783
|
+
}
|
|
12784
|
+
getStagedFiles() {
|
|
12785
|
+
return this.resolveFilesWithGitCommand(["diff", "--cached", "--name-only"]);
|
|
12786
|
+
}
|
|
12787
|
+
getUnstagedFiles() {
|
|
12788
|
+
return this.resolveFilesWithGitCommand([
|
|
12789
|
+
"ls-files",
|
|
12790
|
+
"--other",
|
|
12791
|
+
"--modified",
|
|
12792
|
+
"--exclude-standard"
|
|
12793
|
+
]);
|
|
12794
|
+
}
|
|
12795
|
+
async getRoot(cwd) {
|
|
12796
|
+
const options = ["rev-parse", "--show-cdup"];
|
|
12797
|
+
try {
|
|
12798
|
+
const result = await execa("git", options, { cwd });
|
|
12799
|
+
return resolve(cwd, result.stdout);
|
|
12800
|
+
} catch {
|
|
12801
|
+
return null;
|
|
12802
|
+
}
|
|
12803
|
+
}
|
|
12804
|
+
}
|
|
12805
|
+
|
|
12806
|
+
var __defProp$1 = Object.defineProperty;
|
|
12807
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
12808
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
12809
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
12810
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12811
|
+
var __spreadValues$1 = (a, b) => {
|
|
12812
|
+
for (var prop in b || (b = {}))
|
|
12813
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
12814
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
12815
|
+
if (__getOwnPropSymbols$1)
|
|
12816
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
12817
|
+
if (__propIsEnum$1.call(b, prop))
|
|
12818
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
12819
|
+
}
|
|
12820
|
+
return a;
|
|
12821
|
+
};
|
|
12694
12822
|
const WATCHER_DEBOUNCE = 100;
|
|
12695
12823
|
const CLOSE_TIMEOUT = 1e3;
|
|
12696
12824
|
class Vitest {
|
|
@@ -12722,7 +12850,7 @@ class Vitest {
|
|
|
12722
12850
|
this.server = server;
|
|
12723
12851
|
this.config = resolved;
|
|
12724
12852
|
this.state = new StateManager();
|
|
12725
|
-
this.snapshot = new SnapshotManager(resolved);
|
|
12853
|
+
this.snapshot = new SnapshotManager(__spreadValues$1({}, resolved.snapshotOptions));
|
|
12726
12854
|
this.reporters = resolved.reporters.map((i) => {
|
|
12727
12855
|
if (typeof i === "string") {
|
|
12728
12856
|
const Reporter = ReportersMap[i];
|
|
@@ -12742,6 +12870,8 @@ class Vitest {
|
|
|
12742
12870
|
}
|
|
12743
12871
|
getConfig() {
|
|
12744
12872
|
const hasCustomReporter = toArray(this.config.reporters).some((reporter) => typeof reporter !== "string");
|
|
12873
|
+
if (this.config.snapshotOptions.resolveSnapshotPath)
|
|
12874
|
+
this.config.snapshotOptions.resolveSnapshotPath = void 0;
|
|
12745
12875
|
if (!hasCustomReporter && !this.configOverride)
|
|
12746
12876
|
return this.config;
|
|
12747
12877
|
const config = deepMerge({}, this.config);
|
|
@@ -12799,6 +12929,17 @@ Run with \`--passWithNoTests\`to exit with code 0
|
|
|
12799
12929
|
return deps;
|
|
12800
12930
|
}
|
|
12801
12931
|
async filterTestsBySource(tests) {
|
|
12932
|
+
if (this.config.changed && !this.config.related) {
|
|
12933
|
+
const vitestGit = new VitestGit(this.config.root);
|
|
12934
|
+
const related2 = await vitestGit.findChangedFiles({
|
|
12935
|
+
changedSince: this.config.changed
|
|
12936
|
+
});
|
|
12937
|
+
if (!related2) {
|
|
12938
|
+
this.error(c.red("Could not find Git root. Have you initialized git with `git init`?\n"));
|
|
12939
|
+
process.exit(1);
|
|
12940
|
+
}
|
|
12941
|
+
this.config.related = Array.from(new Set(related2));
|
|
12942
|
+
}
|
|
12802
12943
|
const related = this.config.related;
|
|
12803
12944
|
if (!related)
|
|
12804
12945
|
return tests;
|
|
@@ -12810,7 +12951,7 @@ Run with \`--passWithNoTests\`to exit with code 0
|
|
|
12810
12951
|
}));
|
|
12811
12952
|
const runningTests = [];
|
|
12812
12953
|
for (const [filepath, deps] of testDeps) {
|
|
12813
|
-
if (deps.size && related.some((path) => deps.has(path)))
|
|
12954
|
+
if (deps.size && related.some((path) => path === filepath || deps.has(path)))
|
|
12814
12955
|
runningTests.push(filepath);
|
|
12815
12956
|
}
|
|
12816
12957
|
return runningTests;
|
|
@@ -12903,6 +13044,7 @@ Run with \`--passWithNoTests\`to exit with code 0
|
|
|
12903
13044
|
if (this.state.filesMap.has(id)) {
|
|
12904
13045
|
this.state.filesMap.delete(id);
|
|
12905
13046
|
this.changedTests.delete(id);
|
|
13047
|
+
this.report("onTestRemoved", id);
|
|
12906
13048
|
}
|
|
12907
13049
|
};
|
|
12908
13050
|
const onAdd = async (id) => {
|
|
@@ -13147,6 +13289,12 @@ function hoistMocks(code) {
|
|
|
13147
13289
|
}
|
|
13148
13290
|
return m;
|
|
13149
13291
|
}
|
|
13292
|
+
const API_NOT_FOUND_ERROR = `There are some problems in resolving the mocks API.
|
|
13293
|
+
You may encounter this issue when importing the mocks API from another module other than 'vitest'.
|
|
13294
|
+
|
|
13295
|
+
To fix this issue you can either:
|
|
13296
|
+
- import the mocks API directly from 'vitest'
|
|
13297
|
+
- enable the 'globals' options`;
|
|
13150
13298
|
const MocksPlugin = () => {
|
|
13151
13299
|
return {
|
|
13152
13300
|
name: "vitest:mock-plugin",
|
|
@@ -13155,11 +13303,17 @@ const MocksPlugin = () => {
|
|
|
13155
13303
|
const m = hoistMocks(code);
|
|
13156
13304
|
if (m) {
|
|
13157
13305
|
const vitestImports = code.matchAll(vitestRegexp);
|
|
13306
|
+
let found = false;
|
|
13158
13307
|
for (const match of vitestImports) {
|
|
13159
13308
|
const indexStart = match.index;
|
|
13160
13309
|
const indexEnd = match[0].length + indexStart;
|
|
13161
13310
|
m.remove(indexStart, indexEnd);
|
|
13162
13311
|
m.prepend(`${match[0]}
|
|
13312
|
+
`);
|
|
13313
|
+
found = true;
|
|
13314
|
+
}
|
|
13315
|
+
if (!found) {
|
|
13316
|
+
m.prepend(`try { vi } catch (_) { try { vitest } catch (__){ throw new Error(${JSON.stringify(API_NOT_FOUND_ERROR)}) } }
|
|
13163
13317
|
`);
|
|
13164
13318
|
}
|
|
13165
13319
|
return {
|
|
@@ -13301,7 +13455,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
13301
13455
|
open: preOptions.ui && preOptions.open ? preOptions.uiBase ?? "/__vitest__/" : void 0,
|
|
13302
13456
|
preTransformRequests: false
|
|
13303
13457
|
}),
|
|
13304
|
-
cacheDir: void 0
|
|
13458
|
+
cacheDir: void 0,
|
|
13459
|
+
optimizeDeps: {
|
|
13460
|
+
entries: []
|
|
13461
|
+
}
|
|
13305
13462
|
};
|
|
13306
13463
|
},
|
|
13307
13464
|
async configResolved(viteConfig) {
|
|
@@ -13324,7 +13481,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
13324
13481
|
await ctx.setServer(options, server);
|
|
13325
13482
|
haveStarted = true;
|
|
13326
13483
|
if (options.api && options.watch)
|
|
13327
|
-
(await import('./chunk-api-setup.
|
|
13484
|
+
(await import('./chunk-api-setup.e8071f5b.js')).setup(ctx);
|
|
13328
13485
|
if (!options.watch)
|
|
13329
13486
|
await server.watcher.close();
|
|
13330
13487
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { builtinModules, createRequire } from 'module';
|
|
2
2
|
import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
|
-
import {
|
|
4
|
+
import { l as isAbsolute$2, w as resolve, j as join$2, A as extname$2, k as dirname$2 } from './chunk-utils-global.35d3b35d.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
|
|
7
7
|
import assert from 'assert';
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { d as c } from './chunk-utils-
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
2
|
+
import { d as c } from './chunk-utils-global.35d3b35d.js';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.2004587d.js';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
@@ -16,13 +16,13 @@ import 'util';
|
|
|
16
16
|
import 'url';
|
|
17
17
|
import 'os';
|
|
18
18
|
import 'vite';
|
|
19
|
-
import './chunk-constants.
|
|
20
|
-
import './chunk-vite-node-utils.
|
|
19
|
+
import './chunk-constants.596ee4d5.js';
|
|
20
|
+
import './chunk-vite-node-utils.5fa30ee7.js';
|
|
21
21
|
import 'module';
|
|
22
22
|
import 'vm';
|
|
23
|
-
import './chunk-defaults.
|
|
23
|
+
import './chunk-defaults.731639a8.js';
|
|
24
24
|
import 'perf_hooks';
|
|
25
|
-
import './chunk-utils-timers.
|
|
25
|
+
import './chunk-utils-timers.73950dcb.js';
|
|
26
26
|
import 'worker_threads';
|
|
27
27
|
import 'tinypool';
|
|
28
28
|
import './chunk-magic-string.d5e0e473.js';
|
|
@@ -643,7 +643,7 @@ class CAC extends EventEmitter {
|
|
|
643
643
|
const cac = (name = "") => new CAC(name);
|
|
644
644
|
|
|
645
645
|
const cli = cac("vitest");
|
|
646
|
-
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length").option("--outputFile <filename>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--global", "deprecated, use --globals").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").help();
|
|
646
|
+
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length").option("--outputFile <filename>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--global", "deprecated, use --globals").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").help();
|
|
647
647
|
cli.command("run [...filters]").action(run);
|
|
648
648
|
cli.command("related [...filters]").action(runRelated);
|
|
649
649
|
cli.command("watch [...filters]").action(start);
|
package/dist/config.cjs
CHANGED
|
@@ -27,7 +27,7 @@ const coverageConfigDefaults = {
|
|
|
27
27
|
allowExternal: false,
|
|
28
28
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
29
29
|
};
|
|
30
|
-
const
|
|
30
|
+
const config = {
|
|
31
31
|
allowOnly: !process.env.CI,
|
|
32
32
|
watch: !process.env.CI,
|
|
33
33
|
globals: false,
|
|
@@ -50,7 +50,8 @@ const configDefaults = Object.freeze({
|
|
|
50
50
|
uiBase: "/__vitest__/",
|
|
51
51
|
open: true,
|
|
52
52
|
coverage: coverageConfigDefaults
|
|
53
|
-
}
|
|
53
|
+
};
|
|
54
|
+
const configDefaults = Object.freeze(config);
|
|
54
55
|
|
|
55
56
|
function defineConfig(config) {
|
|
56
57
|
return config;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
import { UserConfig as UserConfig$2 } from 'vite';
|
|
2
|
-
import { UserConfig as UserConfig$1 } from 'vitest';
|
|
2
|
+
import { UserConfig as UserConfig$1, ResolvedC8Options } from 'vitest';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare const config: {
|
|
5
|
+
allowOnly: boolean;
|
|
6
|
+
watch: boolean;
|
|
7
|
+
globals: boolean;
|
|
8
|
+
environment: "node";
|
|
9
|
+
threads: boolean;
|
|
10
|
+
clearMocks: boolean;
|
|
11
|
+
restoreMocks: boolean;
|
|
12
|
+
mockReset: boolean;
|
|
13
|
+
include: string[];
|
|
14
|
+
exclude: string[];
|
|
15
|
+
testTimeout: number;
|
|
16
|
+
hookTimeout: number;
|
|
17
|
+
isolate: boolean;
|
|
18
|
+
watchIgnore: RegExp[];
|
|
19
|
+
update: boolean;
|
|
20
|
+
reporters: never[];
|
|
21
|
+
silent: boolean;
|
|
22
|
+
api: boolean;
|
|
23
|
+
ui: boolean;
|
|
24
|
+
uiBase: string;
|
|
25
|
+
open: boolean;
|
|
26
|
+
coverage: ResolvedC8Options;
|
|
27
|
+
};
|
|
28
|
+
declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
|
|
5
29
|
|
|
6
30
|
interface UserConfig extends UserConfig$2 {
|
|
7
31
|
test?: UserConfig$2['test'];
|