vitest 0.8.4 → 0.9.1
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.7290422e.js} +4 -4
- package/dist/{chunk-constants.6062c404.js → chunk-constants.e59013dc.js} +1 -1
- package/dist/{chunk-defaults.e5535971.js → chunk-defaults.9aa0ce42.js} +4 -3
- package/dist/chunk-integrations-globals.c040aaa9.js +23 -0
- package/dist/{chunk-runtime-chain.766f27fd.js → chunk-runtime-chain.94cf66a4.js} +96 -2458
- package/dist/{chunk-runtime-mocker.d320e5e9.js → chunk-runtime-mocker.7f4b1850.js} +7 -6
- package/dist/chunk-runtime-rpc.4b80b6bd.js +7 -0
- package/dist/{chunk-utils-base.8408f73a.js → chunk-utils-global.10dcdfa6.js} +18 -1
- package/dist/{chunk-utils-timers.7bdeea22.js → chunk-utils-timers.4800834c.js} +2442 -16
- package/dist/{chunk-vite-node-externalize.8c747551.js → chunk-vite-node-externalize.6a2ab9c2.js} +164 -81
- package/dist/{chunk-vite-node-utils.3c7ce184.js → chunk-vite-node-utils.7f0053fb.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 +27 -14
- package/dist/index.js +5 -6
- package/dist/node.d.ts +15 -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 +17 -17
- 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.8c747551.js → chunk-vite-node-externalize.6a2ab9c2.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,
|
|
8
|
+
import { j as join, h as basename, k as dirname, e 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.10dcdfa6.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.e59013dc.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.7f0053fb.js';
|
|
16
|
+
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.9aa0ce42.js';
|
|
17
17
|
import { performance } from 'perf_hooks';
|
|
18
|
-
import {
|
|
18
|
+
import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, s as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, d as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, c as clearTimeout$1 } from './chunk-utils-timers.4800834c.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.1";
|
|
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
|
}
|
|
@@ -11890,6 +11911,14 @@ class DotReporter extends BaseReporter {
|
|
|
11890
11911
|
}
|
|
11891
11912
|
}
|
|
11892
11913
|
|
|
11914
|
+
const getOutputFile = ({ config }, reporter) => {
|
|
11915
|
+
if (!config.outputFile)
|
|
11916
|
+
return;
|
|
11917
|
+
if (typeof config.outputFile === "string")
|
|
11918
|
+
return config.outputFile;
|
|
11919
|
+
return config.outputFile[reporter];
|
|
11920
|
+
};
|
|
11921
|
+
|
|
11893
11922
|
const StatusMap = {
|
|
11894
11923
|
fail: "failed",
|
|
11895
11924
|
only: "pending",
|
|
@@ -12001,8 +12030,9 @@ class JsonReporter {
|
|
|
12001
12030
|
await this.logTasks(files);
|
|
12002
12031
|
}
|
|
12003
12032
|
async writeReport(report) {
|
|
12004
|
-
|
|
12005
|
-
|
|
12033
|
+
const outputFile = getOutputFile(this.ctx, "json");
|
|
12034
|
+
if (outputFile) {
|
|
12035
|
+
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
12006
12036
|
const outputDirectory = dirname(reportFile);
|
|
12007
12037
|
if (!existsSync(outputDirectory))
|
|
12008
12038
|
await promises.mkdir(outputDirectory, { recursive: true });
|
|
@@ -12019,6 +12049,19 @@ class VerboseReporter extends DefaultReporter {
|
|
|
12019
12049
|
super();
|
|
12020
12050
|
this.rendererOptions.renderSucceed = true;
|
|
12021
12051
|
}
|
|
12052
|
+
onTaskUpdate(packs) {
|
|
12053
|
+
var _a, _b, _c;
|
|
12054
|
+
if (this.isTTY)
|
|
12055
|
+
return;
|
|
12056
|
+
for (const pack of packs) {
|
|
12057
|
+
const task = this.ctx.state.idMap.get(pack[0]);
|
|
12058
|
+
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
12059
|
+
this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
|
|
12060
|
+
if (task.result.state === "fail")
|
|
12061
|
+
this.ctx.log(c.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
12062
|
+
}
|
|
12063
|
+
}
|
|
12064
|
+
}
|
|
12022
12065
|
}
|
|
12023
12066
|
|
|
12024
12067
|
class IndentedLogger {
|
|
@@ -12109,21 +12152,21 @@ class TapReporter {
|
|
|
12109
12152
|
}
|
|
12110
12153
|
}
|
|
12111
12154
|
|
|
12112
|
-
var __defProp$
|
|
12155
|
+
var __defProp$4 = Object.defineProperty;
|
|
12113
12156
|
var __defProps$3 = Object.defineProperties;
|
|
12114
12157
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
12115
|
-
var __getOwnPropSymbols$
|
|
12116
|
-
var __hasOwnProp$
|
|
12117
|
-
var __propIsEnum$
|
|
12118
|
-
var __defNormalProp$
|
|
12119
|
-
var __spreadValues$
|
|
12158
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
12159
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
12160
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
12161
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12162
|
+
var __spreadValues$4 = (a, b) => {
|
|
12120
12163
|
for (var prop in b || (b = {}))
|
|
12121
|
-
if (__hasOwnProp$
|
|
12122
|
-
__defNormalProp$
|
|
12123
|
-
if (__getOwnPropSymbols$
|
|
12124
|
-
for (var prop of __getOwnPropSymbols$
|
|
12125
|
-
if (__propIsEnum$
|
|
12126
|
-
__defNormalProp$
|
|
12164
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
12165
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
12166
|
+
if (__getOwnPropSymbols$4)
|
|
12167
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
12168
|
+
if (__propIsEnum$4.call(b, prop))
|
|
12169
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
12127
12170
|
}
|
|
12128
12171
|
return a;
|
|
12129
12172
|
};
|
|
@@ -12133,7 +12176,7 @@ function flattenTasks$1(task, baseName = "") {
|
|
|
12133
12176
|
if (task.type === "suite") {
|
|
12134
12177
|
return task.tasks.flatMap((child) => flattenTasks$1(child, `${base}${task.name}`));
|
|
12135
12178
|
} else {
|
|
12136
|
-
return [__spreadProps$3(__spreadValues$
|
|
12179
|
+
return [__spreadProps$3(__spreadValues$4({}, task), {
|
|
12137
12180
|
name: `${base}${task.name}`
|
|
12138
12181
|
})];
|
|
12139
12182
|
}
|
|
@@ -12148,8 +12191,9 @@ function getDuration(task) {
|
|
|
12148
12191
|
class JUnitReporter {
|
|
12149
12192
|
async onInit(ctx) {
|
|
12150
12193
|
this.ctx = ctx;
|
|
12151
|
-
|
|
12152
|
-
|
|
12194
|
+
const outputFile = getOutputFile(this.ctx, "junit");
|
|
12195
|
+
if (outputFile) {
|
|
12196
|
+
this.reportFile = resolve(this.ctx.config.root, outputFile);
|
|
12153
12197
|
const outputDirectory = dirname(this.reportFile);
|
|
12154
12198
|
if (!existsSync(outputDirectory))
|
|
12155
12199
|
await promises.mkdir(outputDirectory, { recursive: true });
|
|
@@ -12241,7 +12285,7 @@ class JUnitReporter {
|
|
|
12241
12285
|
failures: 0,
|
|
12242
12286
|
skipped: 0
|
|
12243
12287
|
});
|
|
12244
|
-
return __spreadProps$3(__spreadValues$
|
|
12288
|
+
return __spreadProps$3(__spreadValues$4({}, file), {
|
|
12245
12289
|
tasks,
|
|
12246
12290
|
stats
|
|
12247
12291
|
});
|
|
@@ -12267,21 +12311,21 @@ class JUnitReporter {
|
|
|
12267
12311
|
}
|
|
12268
12312
|
}
|
|
12269
12313
|
|
|
12270
|
-
var __defProp$
|
|
12314
|
+
var __defProp$3 = Object.defineProperty;
|
|
12271
12315
|
var __defProps$2 = Object.defineProperties;
|
|
12272
12316
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
12273
|
-
var __getOwnPropSymbols$
|
|
12274
|
-
var __hasOwnProp$
|
|
12275
|
-
var __propIsEnum$
|
|
12276
|
-
var __defNormalProp$
|
|
12277
|
-
var __spreadValues$
|
|
12317
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
12318
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
12319
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
12320
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12321
|
+
var __spreadValues$3 = (a, b) => {
|
|
12278
12322
|
for (var prop in b || (b = {}))
|
|
12279
|
-
if (__hasOwnProp$
|
|
12280
|
-
__defNormalProp$
|
|
12281
|
-
if (__getOwnPropSymbols$
|
|
12282
|
-
for (var prop of __getOwnPropSymbols$
|
|
12283
|
-
if (__propIsEnum$
|
|
12284
|
-
__defNormalProp$
|
|
12323
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
12324
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
12325
|
+
if (__getOwnPropSymbols$3)
|
|
12326
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
12327
|
+
if (__propIsEnum$3.call(b, prop))
|
|
12328
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
12285
12329
|
}
|
|
12286
12330
|
return a;
|
|
12287
12331
|
};
|
|
@@ -12291,7 +12335,7 @@ function flattenTasks(task, baseName = "") {
|
|
|
12291
12335
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
12292
12336
|
return task.tasks.flatMap((child) => flattenTasks(child, `${base}${task.name}`));
|
|
12293
12337
|
} else {
|
|
12294
|
-
return [__spreadProps$2(__spreadValues$
|
|
12338
|
+
return [__spreadProps$2(__spreadValues$3({}, task), {
|
|
12295
12339
|
name: `${base}${task.name}`
|
|
12296
12340
|
})];
|
|
12297
12341
|
}
|
|
@@ -12397,6 +12441,9 @@ function createChannel(ctx) {
|
|
|
12397
12441
|
snapshotSaved(snapshot) {
|
|
12398
12442
|
ctx.snapshot.add(snapshot);
|
|
12399
12443
|
},
|
|
12444
|
+
resolveSnapshotPath(testPath) {
|
|
12445
|
+
return ctx.snapshot.resolvePath(testPath);
|
|
12446
|
+
},
|
|
12400
12447
|
async getSourceMap(id, force) {
|
|
12401
12448
|
if (force) {
|
|
12402
12449
|
const mod = ctx.server.moduleGraph.getModuleById(id);
|
|
@@ -12490,21 +12537,21 @@ class StateManager {
|
|
|
12490
12537
|
}
|
|
12491
12538
|
}
|
|
12492
12539
|
|
|
12493
|
-
var __defProp$
|
|
12540
|
+
var __defProp$2 = Object.defineProperty;
|
|
12494
12541
|
var __defProps$1 = Object.defineProperties;
|
|
12495
12542
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
12496
|
-
var __getOwnPropSymbols$
|
|
12497
|
-
var __hasOwnProp$
|
|
12498
|
-
var __propIsEnum$
|
|
12499
|
-
var __defNormalProp$
|
|
12500
|
-
var __spreadValues$
|
|
12543
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
12544
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
12545
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
12546
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12547
|
+
var __spreadValues$2 = (a, b) => {
|
|
12501
12548
|
for (var prop in b || (b = {}))
|
|
12502
|
-
if (__hasOwnProp$
|
|
12503
|
-
__defNormalProp$
|
|
12504
|
-
if (__getOwnPropSymbols$
|
|
12505
|
-
for (var prop of __getOwnPropSymbols$
|
|
12506
|
-
if (__propIsEnum$
|
|
12507
|
-
__defNormalProp$
|
|
12549
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
12550
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
12551
|
+
if (__getOwnPropSymbols$2)
|
|
12552
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
12553
|
+
if (__propIsEnum$2.call(b, prop))
|
|
12554
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
12508
12555
|
}
|
|
12509
12556
|
return a;
|
|
12510
12557
|
};
|
|
@@ -12534,7 +12581,7 @@ function resolveApiConfig(options) {
|
|
|
12534
12581
|
if (options.api.host)
|
|
12535
12582
|
api.host = options.api.host;
|
|
12536
12583
|
} else {
|
|
12537
|
-
api = __spreadValues$
|
|
12584
|
+
api = __spreadValues$2({}, options.api);
|
|
12538
12585
|
}
|
|
12539
12586
|
}
|
|
12540
12587
|
if (api) {
|
|
@@ -12551,7 +12598,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
12551
12598
|
}
|
|
12552
12599
|
options.environment = "happy-dom";
|
|
12553
12600
|
}
|
|
12554
|
-
const resolved = __spreadProps$1(__spreadValues$
|
|
12601
|
+
const resolved = __spreadProps$1(__spreadValues$2(__spreadValues$2({}, configDefaults), options), {
|
|
12555
12602
|
root: viteConfig.root
|
|
12556
12603
|
});
|
|
12557
12604
|
if (viteConfig.base !== "/")
|
|
@@ -12565,8 +12612,11 @@ function resolveConfig(options, viteConfig) {
|
|
|
12565
12612
|
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
12566
12613
|
resolved.snapshotOptions = {
|
|
12567
12614
|
snapshotFormat: resolved.snapshotFormat || {},
|
|
12568
|
-
updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new"
|
|
12615
|
+
updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
|
|
12616
|
+
resolveSnapshotPath: options.resolveSnapshotPath
|
|
12569
12617
|
};
|
|
12618
|
+
if (options.resolveSnapshotPath)
|
|
12619
|
+
delete resolved.resolveSnapshotPath;
|
|
12570
12620
|
if (process.env.VITEST_MAX_THREADS)
|
|
12571
12621
|
resolved.maxThreads = parseInt(process.env.VITEST_MAX_THREADS);
|
|
12572
12622
|
if (process.env.VITEST_MIN_THREADS)
|
|
@@ -12612,7 +12662,7 @@ async function printError(error, ctx) {
|
|
|
12612
12662
|
});
|
|
12613
12663
|
handleImportOutsideModuleError(e.stack || e.stackStr || "", ctx);
|
|
12614
12664
|
if (e.showDiff)
|
|
12615
|
-
displayDiff(e.actual, e.expected, ctx.console, ctx.config.outputTruncateLength);
|
|
12665
|
+
displayDiff(stringify$5(e.actual), stringify$5(e.expected), ctx.console, ctx.config.outputTruncateLength);
|
|
12616
12666
|
}
|
|
12617
12667
|
const esmErrors = [
|
|
12618
12668
|
"Cannot use import statement outside a module",
|
|
@@ -12643,7 +12693,7 @@ As a temporary workaround you can try to inline the package by updating your con
|
|
|
12643
12693
|
`)));
|
|
12644
12694
|
}
|
|
12645
12695
|
function displayDiff(actual, expected, console, outputTruncateLength) {
|
|
12646
|
-
console.error(c.gray(unifiedDiff(actual, expected, outputTruncateLength)) + "\n");
|
|
12696
|
+
console.error(c.gray(unifiedDiff(actual, expected, { outputTruncateLength })) + "\n");
|
|
12647
12697
|
}
|
|
12648
12698
|
function printErrorMessage(error, console) {
|
|
12649
12699
|
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
@@ -12763,6 +12813,22 @@ class VitestGit {
|
|
|
12763
12813
|
}
|
|
12764
12814
|
}
|
|
12765
12815
|
|
|
12816
|
+
var __defProp$1 = Object.defineProperty;
|
|
12817
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
12818
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
12819
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
12820
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12821
|
+
var __spreadValues$1 = (a, b) => {
|
|
12822
|
+
for (var prop in b || (b = {}))
|
|
12823
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
12824
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
12825
|
+
if (__getOwnPropSymbols$1)
|
|
12826
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
12827
|
+
if (__propIsEnum$1.call(b, prop))
|
|
12828
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
12829
|
+
}
|
|
12830
|
+
return a;
|
|
12831
|
+
};
|
|
12766
12832
|
const WATCHER_DEBOUNCE = 100;
|
|
12767
12833
|
const CLOSE_TIMEOUT = 1e3;
|
|
12768
12834
|
class Vitest {
|
|
@@ -12794,7 +12860,7 @@ class Vitest {
|
|
|
12794
12860
|
this.server = server;
|
|
12795
12861
|
this.config = resolved;
|
|
12796
12862
|
this.state = new StateManager();
|
|
12797
|
-
this.snapshot = new SnapshotManager(resolved);
|
|
12863
|
+
this.snapshot = new SnapshotManager(__spreadValues$1({}, resolved.snapshotOptions));
|
|
12798
12864
|
this.reporters = resolved.reporters.map((i) => {
|
|
12799
12865
|
if (typeof i === "string") {
|
|
12800
12866
|
const Reporter = ReportersMap[i];
|
|
@@ -12814,6 +12880,8 @@ class Vitest {
|
|
|
12814
12880
|
}
|
|
12815
12881
|
getConfig() {
|
|
12816
12882
|
const hasCustomReporter = toArray(this.config.reporters).some((reporter) => typeof reporter !== "string");
|
|
12883
|
+
if (this.config.snapshotOptions.resolveSnapshotPath)
|
|
12884
|
+
this.config.snapshotOptions.resolveSnapshotPath = void 0;
|
|
12817
12885
|
if (!hasCustomReporter && !this.configOverride)
|
|
12818
12886
|
return this.config;
|
|
12819
12887
|
const config = deepMerge({}, this.config);
|
|
@@ -12893,7 +12961,7 @@ Run with \`--passWithNoTests\`to exit with code 0
|
|
|
12893
12961
|
}));
|
|
12894
12962
|
const runningTests = [];
|
|
12895
12963
|
for (const [filepath, deps] of testDeps) {
|
|
12896
|
-
if (deps.size && related.some((path) => deps.has(path)))
|
|
12964
|
+
if (deps.size && related.some((path) => path === filepath || deps.has(path)))
|
|
12897
12965
|
runningTests.push(filepath);
|
|
12898
12966
|
}
|
|
12899
12967
|
return runningTests;
|
|
@@ -13231,6 +13299,12 @@ function hoistMocks(code) {
|
|
|
13231
13299
|
}
|
|
13232
13300
|
return m;
|
|
13233
13301
|
}
|
|
13302
|
+
const API_NOT_FOUND_ERROR = `There are some problems in resolving the mocks API.
|
|
13303
|
+
You may encounter this issue when importing the mocks API from another module other than 'vitest'.
|
|
13304
|
+
|
|
13305
|
+
To fix this issue you can either:
|
|
13306
|
+
- import the mocks API directly from 'vitest'
|
|
13307
|
+
- enable the 'globals' options`;
|
|
13234
13308
|
const MocksPlugin = () => {
|
|
13235
13309
|
return {
|
|
13236
13310
|
name: "vitest:mock-plugin",
|
|
@@ -13239,11 +13313,17 @@ const MocksPlugin = () => {
|
|
|
13239
13313
|
const m = hoistMocks(code);
|
|
13240
13314
|
if (m) {
|
|
13241
13315
|
const vitestImports = code.matchAll(vitestRegexp);
|
|
13316
|
+
let found = false;
|
|
13242
13317
|
for (const match of vitestImports) {
|
|
13243
13318
|
const indexStart = match.index;
|
|
13244
13319
|
const indexEnd = match[0].length + indexStart;
|
|
13245
13320
|
m.remove(indexStart, indexEnd);
|
|
13246
13321
|
m.prepend(`${match[0]}
|
|
13322
|
+
`);
|
|
13323
|
+
found = true;
|
|
13324
|
+
}
|
|
13325
|
+
if (!found) {
|
|
13326
|
+
m.prepend(`try { vi } catch (_) { try { vitest } catch (__){ throw new Error(${JSON.stringify(API_NOT_FOUND_ERROR)}) } }
|
|
13247
13327
|
`);
|
|
13248
13328
|
}
|
|
13249
13329
|
return {
|
|
@@ -13385,7 +13465,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
13385
13465
|
open: preOptions.ui && preOptions.open ? preOptions.uiBase ?? "/__vitest__/" : void 0,
|
|
13386
13466
|
preTransformRequests: false
|
|
13387
13467
|
}),
|
|
13388
|
-
cacheDir: void 0
|
|
13468
|
+
cacheDir: void 0,
|
|
13469
|
+
optimizeDeps: {
|
|
13470
|
+
entries: []
|
|
13471
|
+
}
|
|
13389
13472
|
};
|
|
13390
13473
|
},
|
|
13391
13474
|
async configResolved(viteConfig) {
|
|
@@ -13408,7 +13491,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
13408
13491
|
await ctx.setServer(options, server);
|
|
13409
13492
|
haveStarted = true;
|
|
13410
13493
|
if (options.api && options.watch)
|
|
13411
|
-
(await import('./chunk-api-setup.
|
|
13494
|
+
(await import('./chunk-api-setup.7290422e.js')).setup(ctx);
|
|
13412
13495
|
if (!options.watch)
|
|
13413
13496
|
await server.watcher.close();
|
|
13414
13497
|
}
|
|
@@ -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.10dcdfa6.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 {
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
2
|
+
import { e as c } from './chunk-utils-global.10dcdfa6.js';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.6a2ab9c2.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.e59013dc.js';
|
|
20
|
+
import './chunk-vite-node-utils.7f0053fb.js';
|
|
21
21
|
import 'module';
|
|
22
22
|
import 'vm';
|
|
23
|
-
import './chunk-defaults.
|
|
23
|
+
import './chunk-defaults.9aa0ce42.js';
|
|
24
24
|
import 'perf_hooks';
|
|
25
|
-
import './chunk-utils-timers.
|
|
25
|
+
import './chunk-utils-timers.4800834c.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)").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").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/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of mutliple reporters").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'];
|
package/dist/config.js
CHANGED
|
@@ -23,7 +23,7 @@ const coverageConfigDefaults = {
|
|
|
23
23
|
allowExternal: false,
|
|
24
24
|
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
25
25
|
};
|
|
26
|
-
const
|
|
26
|
+
const config = {
|
|
27
27
|
allowOnly: !process.env.CI,
|
|
28
28
|
watch: !process.env.CI,
|
|
29
29
|
globals: false,
|
|
@@ -46,7 +46,8 @@ const configDefaults = Object.freeze({
|
|
|
46
46
|
uiBase: "/__vitest__/",
|
|
47
47
|
open: true,
|
|
48
48
|
coverage: coverageConfigDefaults
|
|
49
|
-
}
|
|
49
|
+
};
|
|
50
|
+
const configDefaults = Object.freeze(config);
|
|
50
51
|
|
|
51
52
|
function defineConfig(config) {
|
|
52
53
|
return config;
|