vitest 0.25.2 → 0.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +47 -2
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +10 -9
- package/dist/{chunk-api-setup.c5a9009c.js → chunk-api-setup.1c8923c4.js} +4 -2
- package/dist/{chunk-integrations-globals.06c8d418.js → chunk-integrations-globals.789c69e2.js} +7 -7
- package/dist/{chunk-runtime-chain.a0b441dc.js → chunk-runtime-chain.315721df.js} +25 -9
- package/dist/{chunk-runtime-error.6287172c.js → chunk-runtime-error.95c286d7.js} +2 -2
- package/dist/{chunk-runtime-mocker.a5151f99.js → chunk-runtime-mocker.cdc0ec57.js} +35 -19
- package/dist/{chunk-runtime-rpc.1e7530d3.js → chunk-runtime-rpc.b368762d.js} +2 -2
- package/dist/chunk-runtime-setup.80b27439.js +659 -0
- package/dist/{chunk-runtime-test-state.3cbc4575.js → chunk-runtime-test-state.7c288e2d.js} +78 -39
- package/dist/{chunk-typecheck-constants.4891f22f.js → chunk-typecheck-constants.ed987901.js} +12 -2
- package/dist/{chunk-utils-source-map.c6dfbbc1.js → chunk-utils-source-map.29ff1088.js} +3 -1
- package/dist/{chunk-utils-timers.06f993db.js → chunk-utils-timers.b81cda77.js} +2 -0
- package/dist/{chunk-vite-node-externalize.72a4d20b.js → chunk-vite-node-externalize.ddcbafa3.js} +59 -29
- package/dist/{chunk-vite-node-client.85cc7113.js → chunk-vite-node-source-map.61c5ea66.js} +37 -11
- package/dist/{chunk-vite-node-utils.8f0b4a12.js → chunk-vite-node-utils.abe05c5c.js} +105 -120
- package/dist/cli.js +14 -10
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.js +2 -1
- package/dist/entry.js +9 -8
- package/dist/environments.d.ts +1 -1
- package/dist/{index-2f5b6168.d.ts → index-81973d31.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/dist/loader.js +2 -2
- package/dist/node.d.ts +5 -4
- package/dist/node.js +9 -8
- package/dist/suite.js +6 -6
- package/dist/{types-f302dae9.d.ts → types-1cf24598.d.ts} +71 -24
- package/dist/{chunk-runtime-setup.419ccdd8.js → vendor-source-map-support.1ce17397.js} +1 -657
- package/dist/worker.js +9 -7
- package/package.json +6 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.
|
|
2
|
-
import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-typecheck-constants.
|
|
3
|
-
import { p as parseStacktrace } from './chunk-utils-source-map.
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.315721df.js';
|
|
2
|
+
import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-typecheck-constants.ed987901.js';
|
|
3
|
+
import { p as parseStacktrace } from './chunk-utils-source-map.29ff1088.js';
|
|
4
4
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
5
5
|
import util from 'util';
|
|
6
6
|
import { spyOn, fn, isMockFunction, spies } from './spy.js';
|
|
7
|
-
import { s as safeSetTimeout } from './chunk-utils-timers.
|
|
7
|
+
import { s as safeSetTimeout } from './chunk-utils-timers.b81cda77.js';
|
|
8
8
|
import * as chai from 'chai';
|
|
9
9
|
import { assert, should } from 'chai';
|
|
10
10
|
|
|
@@ -89,27 +89,71 @@ if (typeof commonjsGlobal !== "undefined") {
|
|
|
89
89
|
|
|
90
90
|
var global = globalObject$1;
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Is true when the environment causes an error to be thrown for accessing the
|
|
94
|
+
* __proto__ property.
|
|
95
|
+
*
|
|
96
|
+
* This is necessary in order to support `node --disable-proto=throw`.
|
|
97
|
+
*
|
|
98
|
+
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto
|
|
99
|
+
*
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
*/
|
|
102
|
+
let throwsOnProto$1;
|
|
103
|
+
try {
|
|
104
|
+
const object = {};
|
|
105
|
+
// eslint-disable-next-line no-proto, no-unused-expressions
|
|
106
|
+
object.__proto__;
|
|
107
|
+
throwsOnProto$1 = false;
|
|
108
|
+
} catch (_) {
|
|
109
|
+
// This branch is covered when tests are run with `--disable-proto=throw`,
|
|
110
|
+
// however we can test both branches at the same time, so this is ignored
|
|
111
|
+
/* istanbul ignore next */
|
|
112
|
+
throwsOnProto$1 = true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var throwsOnProto_1 = throwsOnProto$1;
|
|
116
|
+
|
|
92
117
|
var call = Function.call;
|
|
118
|
+
var throwsOnProto = throwsOnProto_1;
|
|
119
|
+
|
|
120
|
+
var disallowedProperties = [
|
|
121
|
+
// ignore size because it throws from Map
|
|
122
|
+
"size",
|
|
123
|
+
"caller",
|
|
124
|
+
"callee",
|
|
125
|
+
"arguments",
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
// This branch is covered when tests are run with `--disable-proto=throw`,
|
|
129
|
+
// however we can test both branches at the same time, so this is ignored
|
|
130
|
+
/* istanbul ignore next */
|
|
131
|
+
if (throwsOnProto) {
|
|
132
|
+
disallowedProperties.push("__proto__");
|
|
133
|
+
}
|
|
93
134
|
|
|
94
|
-
var
|
|
135
|
+
var copyPrototypeMethods = function copyPrototypeMethods(prototype) {
|
|
95
136
|
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
|
|
96
|
-
return Object.getOwnPropertyNames(prototype).reduce(function(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
name !== "arguments" &&
|
|
103
|
-
typeof prototype[name] === "function"
|
|
104
|
-
) {
|
|
105
|
-
result[name] = call.bind(prototype[name]);
|
|
137
|
+
return Object.getOwnPropertyNames(prototype).reduce(function (
|
|
138
|
+
result,
|
|
139
|
+
name
|
|
140
|
+
) {
|
|
141
|
+
if (disallowedProperties.includes(name)) {
|
|
142
|
+
return result;
|
|
106
143
|
}
|
|
107
144
|
|
|
145
|
+
if (typeof prototype[name] !== "function") {
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
result[name] = call.bind(prototype[name]);
|
|
150
|
+
|
|
108
151
|
return result;
|
|
109
|
-
},
|
|
152
|
+
},
|
|
153
|
+
Object.create(null));
|
|
110
154
|
};
|
|
111
155
|
|
|
112
|
-
var copyPrototype$5 =
|
|
156
|
+
var copyPrototype$5 = copyPrototypeMethods;
|
|
113
157
|
|
|
114
158
|
var array = copyPrototype$5(Array.prototype);
|
|
115
159
|
|
|
@@ -237,8 +281,8 @@ var deprecated = {};
|
|
|
237
281
|
* @param {string} msg
|
|
238
282
|
* @returns {Function}
|
|
239
283
|
*/
|
|
240
|
-
exports.wrap = function(func, msg) {
|
|
241
|
-
var wrapped = function() {
|
|
284
|
+
exports.wrap = function (func, msg) {
|
|
285
|
+
var wrapped = function () {
|
|
242
286
|
exports.printWarning(msg);
|
|
243
287
|
return func.apply(this, arguments);
|
|
244
288
|
};
|
|
@@ -256,15 +300,8 @@ var deprecated = {};
|
|
|
256
300
|
* @param {string} funcName
|
|
257
301
|
* @returns {string}
|
|
258
302
|
*/
|
|
259
|
-
exports.defaultMsg = function(packageName, funcName) {
|
|
260
|
-
return
|
|
261
|
-
packageName +
|
|
262
|
-
"." +
|
|
263
|
-
funcName +
|
|
264
|
-
" is deprecated and will be removed from the public API in a future version of " +
|
|
265
|
-
packageName +
|
|
266
|
-
"."
|
|
267
|
-
);
|
|
303
|
+
exports.defaultMsg = function (packageName, funcName) {
|
|
304
|
+
return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
|
|
268
305
|
};
|
|
269
306
|
|
|
270
307
|
/**
|
|
@@ -273,7 +310,7 @@ var deprecated = {};
|
|
|
273
310
|
* @param {string} msg
|
|
274
311
|
* @returns {undefined}
|
|
275
312
|
*/
|
|
276
|
-
exports.printWarning = function(msg) {
|
|
313
|
+
exports.printWarning = function (msg) {
|
|
277
314
|
/* istanbul ignore next */
|
|
278
315
|
if (typeof process === "object" && process.emitWarning) {
|
|
279
316
|
// Emit Warnings in Node
|
|
@@ -299,7 +336,7 @@ var every = function every(obj, fn) {
|
|
|
299
336
|
|
|
300
337
|
try {
|
|
301
338
|
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
|
|
302
|
-
obj.forEach(function() {
|
|
339
|
+
obj.forEach(function () {
|
|
303
340
|
if (!fn.apply(this, arguments)) {
|
|
304
341
|
// Throwing an error is the only way to break `forEach`
|
|
305
342
|
throw new Error();
|
|
@@ -347,23 +384,23 @@ function orderByFirstCall(spies) {
|
|
|
347
384
|
|
|
348
385
|
var orderByFirstCall_1 = orderByFirstCall;
|
|
349
386
|
|
|
350
|
-
var copyPrototype$4 =
|
|
387
|
+
var copyPrototype$4 = copyPrototypeMethods;
|
|
351
388
|
|
|
352
389
|
var _function = copyPrototype$4(Function.prototype);
|
|
353
390
|
|
|
354
|
-
var copyPrototype$3 =
|
|
391
|
+
var copyPrototype$3 = copyPrototypeMethods;
|
|
355
392
|
|
|
356
393
|
var map = copyPrototype$3(Map.prototype);
|
|
357
394
|
|
|
358
|
-
var copyPrototype$2 =
|
|
395
|
+
var copyPrototype$2 = copyPrototypeMethods;
|
|
359
396
|
|
|
360
397
|
var object = copyPrototype$2(Object.prototype);
|
|
361
398
|
|
|
362
|
-
var copyPrototype$1 =
|
|
399
|
+
var copyPrototype$1 = copyPrototypeMethods;
|
|
363
400
|
|
|
364
401
|
var set = copyPrototype$1(Set.prototype);
|
|
365
402
|
|
|
366
|
-
var copyPrototype =
|
|
403
|
+
var copyPrototype = copyPrototypeMethods;
|
|
367
404
|
|
|
368
405
|
var string = copyPrototype(String.prototype);
|
|
369
406
|
|
|
@@ -373,7 +410,7 @@ var prototypes = {
|
|
|
373
410
|
map: map,
|
|
374
411
|
object: object,
|
|
375
412
|
set: set,
|
|
376
|
-
string: string
|
|
413
|
+
string: string,
|
|
377
414
|
};
|
|
378
415
|
|
|
379
416
|
var typeDetect = {exports: {}};
|
|
@@ -804,7 +841,7 @@ var lib = {
|
|
|
804
841
|
orderByFirstCall: orderByFirstCall_1,
|
|
805
842
|
prototypes: prototypes,
|
|
806
843
|
typeOf: typeOf,
|
|
807
|
-
valueToString: valueToString_1
|
|
844
|
+
valueToString: valueToString_1,
|
|
808
845
|
};
|
|
809
846
|
|
|
810
847
|
const globalObject = lib.global;
|
|
@@ -2808,11 +2845,13 @@ class VitestUtils {
|
|
|
2808
2845
|
const state = getWorkerState();
|
|
2809
2846
|
const promises = [];
|
|
2810
2847
|
for (const mod of state.moduleCache.values()) {
|
|
2811
|
-
if (mod.promise)
|
|
2848
|
+
if (mod.promise && !mod.evaluated)
|
|
2812
2849
|
promises.push(mod.promise);
|
|
2813
2850
|
}
|
|
2851
|
+
if (!promises.length)
|
|
2852
|
+
return;
|
|
2814
2853
|
await Promise.allSettled(promises);
|
|
2815
|
-
await new Promise((resolve) => safeSetTimeout(resolve, 1)).then(() => Promise.resolve());
|
|
2854
|
+
await new Promise((resolve) => safeSetTimeout(resolve, 1)).then(() => Promise.resolve()).then(() => this.dynamicImportSettled());
|
|
2816
2855
|
}
|
|
2817
2856
|
setConfig(config) {
|
|
2818
2857
|
const state = getWorkerState();
|
package/dist/{chunk-typecheck-constants.4891f22f.js → chunk-typecheck-constants.ed987901.js}
RENAMED
|
@@ -230,7 +230,7 @@ function getWorkerState() {
|
|
|
230
230
|
return globalThis.__vitest_worker__;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
isNode && process.platform === "win32";
|
|
233
|
+
const isWindows = isNode && process.platform === "win32";
|
|
234
234
|
const getRunMode = () => getWorkerState().config.mode;
|
|
235
235
|
const isRunningInTest = () => getRunMode() === "test";
|
|
236
236
|
const isRunningInBenchmark = () => getRunMode() === "benchmark";
|
|
@@ -344,5 +344,15 @@ function createDefer() {
|
|
|
344
344
|
p.reject = reject;
|
|
345
345
|
return p;
|
|
346
346
|
}
|
|
347
|
+
function objectAttr(source, path, defaultValue = void 0) {
|
|
348
|
+
const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
349
|
+
let result = source;
|
|
350
|
+
for (const p of paths) {
|
|
351
|
+
result = Object(result)[p];
|
|
352
|
+
if (result === void 0)
|
|
353
|
+
return defaultValue;
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
347
357
|
|
|
348
|
-
export { AggregateErrorPonyfill as A,
|
|
358
|
+
export { AggregateErrorPonyfill as A, hasFailedSnapshot as B, getTypecheckTests as C, getSuites as D, isTypecheckTest as E, deepMerge as F, removeUndefinedValues as G, isWindows as H, stdout as I, mergeSlashes as J, getAllMockableProperties as K, RealDate as R, TYPECHECK_SUITE as T, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, relativePath as k, shuffle as l, mockDate as m, noop as n, objectAttr as o, partitionSuiteChildren as p, hasTests as q, resetDate as r, slash as s, toArray as t, hasFailed as u, createDefer as v, deepClone as w, getType as x, ensurePackageInstalled as y, getTests as z };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { s as slash, j as notNullish } from './chunk-typecheck-constants.
|
|
1
|
+
import { s as slash, j as notNullish } from './chunk-typecheck-constants.ed987901.js';
|
|
2
2
|
|
|
3
3
|
const lineSplitRE = /\r?\n/;
|
|
4
4
|
const stackIgnorePatterns = [
|
|
5
5
|
"node:internal",
|
|
6
6
|
"/vitest/dist/",
|
|
7
|
+
"/vite-node/dist",
|
|
8
|
+
"/vite-node/src",
|
|
7
9
|
"/vitest/src/",
|
|
8
10
|
"/node_modules/chai/",
|
|
9
11
|
"/node_modules/tinypool/",
|
|
@@ -4000,6 +4000,7 @@ function stringify(object, maxDepth = 10, options) {
|
|
|
4000
4000
|
try {
|
|
4001
4001
|
result = format_1(object, {
|
|
4002
4002
|
maxDepth,
|
|
4003
|
+
escapeString: false,
|
|
4003
4004
|
plugins: PLUGINS,
|
|
4004
4005
|
...options
|
|
4005
4006
|
});
|
|
@@ -4007,6 +4008,7 @@ function stringify(object, maxDepth = 10, options) {
|
|
|
4007
4008
|
result = format_1(object, {
|
|
4008
4009
|
callToJSON: false,
|
|
4009
4010
|
maxDepth,
|
|
4011
|
+
escapeString: false,
|
|
4010
4012
|
plugins: PLUGINS,
|
|
4011
4013
|
...options
|
|
4012
4014
|
});
|
package/dist/{chunk-vite-node-externalize.72a4d20b.js → chunk-vite-node-externalize.ddcbafa3.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as resolve, p as picocolors, j as join, c as basename, d as dirname, r as relative, e as distDir, f as rootDir, g as isAbsolute, i as isNode, h as configFiles, k as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.03f840f2.js';
|
|
2
2
|
import { p as pLimit, s as someTasksAreOnly, i as interpretTaskModes, g as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.befed097.js';
|
|
3
3
|
import { g as getEnvPackageName } from './chunk-env-node.67948209.js';
|
|
4
|
-
import { T as TYPECHECK_SUITE,
|
|
4
|
+
import { T as TYPECHECK_SUITE, y as ensurePackageInstalled, A as AggregateErrorPonyfill, s as slash$2, k as relativePath, z as getTests, e as getFullName, u as hasFailed, B as hasFailedSnapshot, C as getTypecheckTests, D as getSuites, E as isTypecheckTest, j as notNullish, l as shuffle, t as toArray$1, n as noop$1, F as deepMerge, b as getCallLastIndex, G as removeUndefinedValues, H as isWindows, I as stdout } from './chunk-typecheck-constants.ed987901.js';
|
|
5
5
|
import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
|
|
6
6
|
import path$a from 'path';
|
|
7
7
|
import url, { fileURLToPath } from 'url';
|
|
@@ -12,10 +12,10 @@ import util$2 from 'util';
|
|
|
12
12
|
import require$$0$1 from 'stream';
|
|
13
13
|
import require$$2 from 'events';
|
|
14
14
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
15
|
-
import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-
|
|
15
|
+
import { w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-source-map.61c5ea66.js';
|
|
16
16
|
import { performance } from 'perf_hooks';
|
|
17
17
|
import createDebug from 'debug';
|
|
18
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath
|
|
18
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath } from './chunk-vite-node-utils.abe05c5c.js';
|
|
19
19
|
import { writeFile, rm } from 'fs/promises';
|
|
20
20
|
import { e as execa } from './vendor-index.737c3cff.js';
|
|
21
21
|
import { SourceMapConsumer } from 'source-map';
|
|
@@ -24,8 +24,8 @@ import { parse as parse$4 } from 'acorn';
|
|
|
24
24
|
import { ancestor } from 'acorn-walk';
|
|
25
25
|
import { MessageChannel } from 'worker_threads';
|
|
26
26
|
import { Tinypool } from 'tinypool';
|
|
27
|
-
import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.
|
|
28
|
-
import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.
|
|
27
|
+
import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.b81cda77.js';
|
|
28
|
+
import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.29ff1088.js';
|
|
29
29
|
import { resolveModule } from 'local-pkg';
|
|
30
30
|
import { createHash } from 'crypto';
|
|
31
31
|
import { o as onetime } from './vendor-index.9c919048.js';
|
|
@@ -35,7 +35,7 @@ import { stripLiteral } from 'strip-literal';
|
|
|
35
35
|
import require$$0$2 from 'readline';
|
|
36
36
|
import { p as prompts } from './vendor-index.9f20a9be.js';
|
|
37
37
|
|
|
38
|
-
var version$1 = "0.25.
|
|
38
|
+
var version$1 = "0.25.4";
|
|
39
39
|
|
|
40
40
|
class EndError extends Error {
|
|
41
41
|
constructor(value) {
|
|
@@ -7860,7 +7860,6 @@ const WAIT_FOR_CHANGE_PASS = `
|
|
|
7860
7860
|
${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.green(" PASS ")))}${picocolors.exports.green(" Waiting for file changes...")}`;
|
|
7861
7861
|
const WAIT_FOR_CHANGE_FAIL = `
|
|
7862
7862
|
${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.red(" FAIL ")))}${picocolors.exports.red(" Tests failed. Watching for file changes...")}`;
|
|
7863
|
-
const DURATION_LONG$2 = 300;
|
|
7864
7863
|
const LAST_RUN_LOG_TIMEOUT = 1500;
|
|
7865
7864
|
class BaseReporter {
|
|
7866
7865
|
constructor() {
|
|
@@ -7915,7 +7914,7 @@ class BaseReporter {
|
|
|
7915
7914
|
state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.yellow(`${skipped.length} skipped`)}`;
|
|
7916
7915
|
let suffix = picocolors.exports.dim(" (") + state + picocolors.exports.dim(")");
|
|
7917
7916
|
if (task.result.duration) {
|
|
7918
|
-
const color = task.result.duration >
|
|
7917
|
+
const color = task.result.duration > this.ctx.config.slowTestThreshold ? picocolors.exports.yellow : picocolors.exports.gray;
|
|
7919
7918
|
suffix += color(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
|
|
7920
7919
|
}
|
|
7921
7920
|
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
@@ -8532,10 +8531,10 @@ class JsonReporter$1 {
|
|
|
8532
8531
|
assertionResults,
|
|
8533
8532
|
startTime,
|
|
8534
8533
|
endTime,
|
|
8535
|
-
status: tests2.
|
|
8536
|
-
var _a2
|
|
8537
|
-
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "
|
|
8538
|
-
}) ? "
|
|
8534
|
+
status: tests2.some((t) => {
|
|
8535
|
+
var _a2;
|
|
8536
|
+
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
8537
|
+
}) ? "failed" : "passed",
|
|
8539
8538
|
message: ((_b = (_a = file.result) == null ? void 0 : _a.error) == null ? void 0 : _b.message) ?? "",
|
|
8540
8539
|
name: file.filepath
|
|
8541
8540
|
});
|
|
@@ -8726,12 +8725,18 @@ function escapeXML(value) {
|
|
|
8726
8725
|
true
|
|
8727
8726
|
);
|
|
8728
8727
|
}
|
|
8728
|
+
function executionTime(durationMS) {
|
|
8729
|
+
return (durationMS / 1e3).toLocaleString(void 0, { useGrouping: false, maximumFractionDigits: 10 });
|
|
8730
|
+
}
|
|
8729
8731
|
function getDuration(task) {
|
|
8730
8732
|
var _a;
|
|
8731
8733
|
const duration = ((_a = task.result) == null ? void 0 : _a.duration) ?? 0;
|
|
8732
|
-
return (duration
|
|
8734
|
+
return executionTime(duration);
|
|
8733
8735
|
}
|
|
8734
8736
|
class JUnitReporter {
|
|
8737
|
+
constructor() {
|
|
8738
|
+
this._timeStart = new Date();
|
|
8739
|
+
}
|
|
8735
8740
|
async onInit(ctx) {
|
|
8736
8741
|
this.ctx = ctx;
|
|
8737
8742
|
const outputFile = getOutputFile(this.ctx.config, "junit");
|
|
@@ -8746,6 +8751,7 @@ class JUnitReporter {
|
|
|
8746
8751
|
} else {
|
|
8747
8752
|
this.baseLog = async (text) => this.ctx.logger.log(text);
|
|
8748
8753
|
}
|
|
8754
|
+
this._timeStart = new Date();
|
|
8749
8755
|
this.logger = new IndentedLogger(this.baseLog);
|
|
8750
8756
|
}
|
|
8751
8757
|
async writeElement(name, attrs, children) {
|
|
@@ -8798,7 +8804,7 @@ class JUnitReporter {
|
|
|
8798
8804
|
await this.writeLogs(task, "out");
|
|
8799
8805
|
await this.writeLogs(task, "err");
|
|
8800
8806
|
if (task.mode === "skip" || task.mode === "todo")
|
|
8801
|
-
this.logger.log("<skipped/>");
|
|
8807
|
+
await this.logger.log("<skipped/>");
|
|
8802
8808
|
if (((_a = task.result) == null ? void 0 : _a.state) === "fail") {
|
|
8803
8809
|
const error = task.result.error;
|
|
8804
8810
|
await this.writeElement("failure", {
|
|
@@ -8817,13 +8823,13 @@ class JUnitReporter {
|
|
|
8817
8823
|
await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
|
|
8818
8824
|
const transformed = files.map((file) => {
|
|
8819
8825
|
const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
|
|
8820
|
-
const
|
|
8821
|
-
(
|
|
8826
|
+
const stats2 = tasks.reduce(
|
|
8827
|
+
(stats3, task) => {
|
|
8822
8828
|
var _a, _b;
|
|
8823
8829
|
return {
|
|
8824
|
-
passed:
|
|
8825
|
-
failures:
|
|
8826
|
-
skipped:
|
|
8830
|
+
passed: stats3.passed + Number(((_a = task.result) == null ? void 0 : _a.state) === "pass"),
|
|
8831
|
+
failures: stats3.failures + Number(((_b = task.result) == null ? void 0 : _b.state) === "fail"),
|
|
8832
|
+
skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
|
|
8827
8833
|
};
|
|
8828
8834
|
},
|
|
8829
8835
|
{
|
|
@@ -8835,10 +8841,21 @@ class JUnitReporter {
|
|
|
8835
8841
|
return {
|
|
8836
8842
|
...file,
|
|
8837
8843
|
tasks,
|
|
8838
|
-
stats
|
|
8844
|
+
stats: stats2
|
|
8839
8845
|
};
|
|
8840
8846
|
});
|
|
8841
|
-
|
|
8847
|
+
const stats = transformed.reduce((stats2, file) => {
|
|
8848
|
+
stats2.tests += file.tasks.length;
|
|
8849
|
+
stats2.failures += file.stats.failures;
|
|
8850
|
+
return stats2;
|
|
8851
|
+
}, {
|
|
8852
|
+
name: process.env.VITEST_JUNIT_SUITE_NAME || "vitest tests",
|
|
8853
|
+
tests: 0,
|
|
8854
|
+
failures: 0,
|
|
8855
|
+
errors: 0,
|
|
8856
|
+
time: executionTime(new Date().getTime() - this._timeStart.getTime())
|
|
8857
|
+
});
|
|
8858
|
+
await this.writeElement("testsuites", stats, async () => {
|
|
8842
8859
|
for (const file of transformed) {
|
|
8843
8860
|
await this.writeElement("testsuite", {
|
|
8844
8861
|
name: file.name,
|
|
@@ -9386,7 +9403,8 @@ const config = {
|
|
|
9386
9403
|
checker: "tsc",
|
|
9387
9404
|
include: ["**/*.{test,spec}-d.{ts,js}"],
|
|
9388
9405
|
exclude: defaultExclude
|
|
9389
|
-
}
|
|
9406
|
+
},
|
|
9407
|
+
slowTestThreshold: 300
|
|
9390
9408
|
};
|
|
9391
9409
|
const configDefaults = Object.freeze(config);
|
|
9392
9410
|
|
|
@@ -10188,7 +10206,7 @@ createLogUpdate(process$1.stdout);
|
|
|
10188
10206
|
|
|
10189
10207
|
createLogUpdate(process$1.stderr);
|
|
10190
10208
|
|
|
10191
|
-
var version = "0.25.
|
|
10209
|
+
var version = "0.25.4";
|
|
10192
10210
|
|
|
10193
10211
|
function fileFromParsedStack(stack) {
|
|
10194
10212
|
var _a, _b;
|
|
@@ -10593,10 +10611,13 @@ class Vitest {
|
|
|
10593
10611
|
checker.onParseEnd(async ({ files, sourceErrors }) => {
|
|
10594
10612
|
this.state.collectFiles(checker.getTestFiles());
|
|
10595
10613
|
await this.report("onCollected");
|
|
10596
|
-
if (!files.length)
|
|
10614
|
+
if (!files.length) {
|
|
10597
10615
|
this.logger.printNoTestFound();
|
|
10598
|
-
else
|
|
10616
|
+
} else {
|
|
10617
|
+
if (hasFailed(files))
|
|
10618
|
+
process.exitCode = 1;
|
|
10599
10619
|
await this.report("onFinished", files);
|
|
10620
|
+
}
|
|
10600
10621
|
if (sourceErrors.length && !this.config.typecheck.ignoreSourceErrors) {
|
|
10601
10622
|
process.exitCode = 1;
|
|
10602
10623
|
await this.logger.printSourceTypeErrors(sourceErrors);
|
|
@@ -10904,6 +10925,7 @@ class Vitest {
|
|
|
10904
10925
|
const { include, exclude, includeSource } = this.config;
|
|
10905
10926
|
const globOptions = {
|
|
10906
10927
|
absolute: true,
|
|
10928
|
+
dot: true,
|
|
10907
10929
|
cwd: this.config.dir || this.config.root,
|
|
10908
10930
|
ignore: exclude
|
|
10909
10931
|
};
|
|
@@ -10965,7 +10987,7 @@ const EnvReplacerPlugin = () => {
|
|
|
10965
10987
|
return {
|
|
10966
10988
|
name: "vitest:env-replacer",
|
|
10967
10989
|
enforce: "pre",
|
|
10968
|
-
transform(code) {
|
|
10990
|
+
transform(code, id) {
|
|
10969
10991
|
if (!/\bimport\.meta\.env\b/g.test(code))
|
|
10970
10992
|
return null;
|
|
10971
10993
|
let s = null;
|
|
@@ -10979,7 +11001,7 @@ const EnvReplacerPlugin = () => {
|
|
|
10979
11001
|
if (s) {
|
|
10980
11002
|
return {
|
|
10981
11003
|
code: s.toString(),
|
|
10982
|
-
map: s.generateMap({ hires: true })
|
|
11004
|
+
map: s.generateMap({ hires: true, source: id })
|
|
10983
11005
|
};
|
|
10984
11006
|
}
|
|
10985
11007
|
}
|
|
@@ -11055,7 +11077,7 @@ ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inve
|
|
|
11055
11077
|
};
|
|
11056
11078
|
};
|
|
11057
11079
|
|
|
11058
|
-
const hoistRegexp = /^ *\b((?:vitest|vi)\s*.\s*(mock|unmock)\(["`'\s]+(.*[@\w_-]+)["`'\s]+)[),]{1};?/gm;
|
|
11080
|
+
const hoistRegexp = /^[ \t]*\b((?:vitest|vi)\s*.\s*(mock|unmock)\(["`'\s]+(.*[@\w_-]+)["`'\s]+)[),]{1};?/gm;
|
|
11059
11081
|
const vitestRegexp = /import {[^}]*}.*(?=["'`]vitest["`']).*/gm;
|
|
11060
11082
|
function hoistMocks(code) {
|
|
11061
11083
|
let m;
|
|
@@ -11296,6 +11318,9 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11296
11318
|
else if (preOptions.browser)
|
|
11297
11319
|
open = "/";
|
|
11298
11320
|
const config = {
|
|
11321
|
+
esbuild: {
|
|
11322
|
+
sourcemap: "external"
|
|
11323
|
+
},
|
|
11299
11324
|
resolve: {
|
|
11300
11325
|
mainFields: [],
|
|
11301
11326
|
alias: preOptions.alias,
|
|
@@ -11357,7 +11382,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11357
11382
|
try {
|
|
11358
11383
|
await ctx.setServer(options, server);
|
|
11359
11384
|
if (options.api && options.watch)
|
|
11360
|
-
(await import('./chunk-api-setup.
|
|
11385
|
+
(await import('./chunk-api-setup.1c8923c4.js')).setup(ctx);
|
|
11361
11386
|
} catch (err) {
|
|
11362
11387
|
ctx.logger.printError(err, true);
|
|
11363
11388
|
process.exit(1);
|
|
@@ -11416,6 +11441,11 @@ function registerConsoleShortcuts(ctx) {
|
|
|
11416
11441
|
async function _keypressHandler(str, key) {
|
|
11417
11442
|
if (str === "" || str === "\x1B" || key && key.ctrl && key.name === "c")
|
|
11418
11443
|
return ctx.exit(true);
|
|
11444
|
+
if (!isWindows && key && key.ctrl && key.name === "z") {
|
|
11445
|
+
process.kill(process.ppid, "SIGTSTP");
|
|
11446
|
+
process.kill(process.pid, "SIGTSTP");
|
|
11447
|
+
return;
|
|
11448
|
+
}
|
|
11419
11449
|
if (ctx.runningPromise)
|
|
11420
11450
|
return;
|
|
11421
11451
|
const name = key == null ? void 0 : key.name;
|
|
@@ -2,8 +2,34 @@ import { createRequire } from 'module';
|
|
|
2
2
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
4
|
import { b as resolve, d as dirname, g as isAbsolute, l as extname } from './chunk-utils-env.03f840f2.js';
|
|
5
|
-
import { s as slash, n as normalizeRequestId, b as toFilePath, c as isPrimitive, i as isNodeBuiltin, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.
|
|
5
|
+
import { s as slash, n as normalizeRequestId, b as toFilePath, c as isPrimitive, i as isNodeBuiltin, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.abe05c5c.js';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
|
+
import './vendor-source-map-support.1ce17397.js';
|
|
8
|
+
|
|
9
|
+
let SOURCEMAPPING_URL = "sourceMa";
|
|
10
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
11
|
+
const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;source=vite-node`;
|
|
12
|
+
const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
|
|
13
|
+
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`);
|
|
14
|
+
async function withInlineSourcemap(result) {
|
|
15
|
+
const { code, map } = result;
|
|
16
|
+
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_URL))
|
|
17
|
+
return result;
|
|
18
|
+
if (OTHER_SOURCE_MAP_REGEXP.test(code))
|
|
19
|
+
result.code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
|
|
20
|
+
result.code = `${code}
|
|
21
|
+
|
|
22
|
+
//# ${VITE_NODE_SOURCEMAPPING_URL};base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}
|
|
23
|
+
`;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function extractSourceMap(code) {
|
|
27
|
+
var _a;
|
|
28
|
+
const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? void 0 : _a[1];
|
|
29
|
+
if (mapString)
|
|
30
|
+
return JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
7
33
|
|
|
8
34
|
const debugExecute = createDebug("vite-node:client:execute");
|
|
9
35
|
const debugNative = createDebug("vite-node:client:native");
|
|
@@ -96,14 +122,11 @@ class ModuleCacheMap extends Map {
|
|
|
96
122
|
return invalidated;
|
|
97
123
|
}
|
|
98
124
|
getSourceMap(id) {
|
|
99
|
-
|
|
100
|
-
const fsPath = this.normalizePath(id);
|
|
101
|
-
const cache = this.get(fsPath);
|
|
125
|
+
const cache = this.get(id);
|
|
102
126
|
if (cache.map)
|
|
103
127
|
return cache.map;
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const map = JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
|
|
128
|
+
const map = cache.code && extractSourceMap(cache.code);
|
|
129
|
+
if (map) {
|
|
107
130
|
cache.map = map;
|
|
108
131
|
return map;
|
|
109
132
|
}
|
|
@@ -140,7 +163,10 @@ class ViteNodeRunner {
|
|
|
140
163
|
if (mod.promise)
|
|
141
164
|
return mod.promise;
|
|
142
165
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
143
|
-
Object.assign(mod, { promise });
|
|
166
|
+
Object.assign(mod, { promise, evaluated: false });
|
|
167
|
+
promise.finally(() => {
|
|
168
|
+
mod.evaluated = true;
|
|
169
|
+
});
|
|
144
170
|
return await promise;
|
|
145
171
|
}
|
|
146
172
|
async directRequest(id, fsPath, _callstack) {
|
|
@@ -219,7 +245,7 @@ ${getStack()}`), 2e3);
|
|
|
219
245
|
return true;
|
|
220
246
|
}
|
|
221
247
|
});
|
|
222
|
-
Object.assign(mod, { code: transformed, exports });
|
|
248
|
+
Object.assign(mod, { code: transformed, exports, evaluated: false });
|
|
223
249
|
const __filename = fileURLToPath(url);
|
|
224
250
|
const moduleProxy = {
|
|
225
251
|
set exports(value) {
|
|
@@ -318,7 +344,7 @@ function defineExport(exports, key, value) {
|
|
|
318
344
|
function exportAll(exports, sourceModule) {
|
|
319
345
|
if (exports === sourceModule)
|
|
320
346
|
return;
|
|
321
|
-
if (
|
|
347
|
+
if (isPrimitive(sourceModule) || Array.isArray(sourceModule))
|
|
322
348
|
return;
|
|
323
349
|
for (const key in sourceModule) {
|
|
324
350
|
if (key !== "default") {
|
|
@@ -400,4 +426,4 @@ function nanoid(size = 21) {
|
|
|
400
426
|
return id;
|
|
401
427
|
}
|
|
402
428
|
|
|
403
|
-
export { ModuleCacheMap as M, ViteNodeRunner as V, createBirpc as c };
|
|
429
|
+
export { ModuleCacheMap as M, ViteNodeRunner as V, createBirpc as c, withInlineSourcemap as w };
|