vitest 0.10.4 → 0.12.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.0baa5b9c.js → chunk-api-setup.87a943bf.js} +4 -4
- package/dist/{chunk-constants.54c46a47.js → chunk-constants.0567483c.js} +1 -1
- package/dist/{chunk-defaults.c143550b.js → chunk-defaults.23b3ae8a.js} +2 -2
- package/dist/{chunk-integrations-globals.6bdc721a.js → chunk-integrations-globals.a37b2801.js} +8 -8
- package/dist/{chunk-integrations-spy.f036df6f.js → chunk-integrations-spy.bee66426.js} +1 -1
- package/dist/{chunk-runtime-chain.0ac0691b.js → chunk-runtime-chain.37b69607.js} +12 -10
- package/dist/{chunk-runtime-mocker.89015cf8.js → chunk-runtime-mocker.ee72d19a.js} +11 -7
- package/dist/{chunk-runtime-rpc.710f6f7f.js → chunk-runtime-rpc.63398738.js} +1 -1
- package/dist/{chunk-utils-global.eb31f3da.js → chunk-utils-global.a5a8641f.js} +3 -3
- package/dist/{chunk-utils-timers.8a5e7cd5.js → chunk-utils-timers.f25e8f44.js} +2 -2
- package/dist/{chunk-vite-node-externalize.92c54acc.js → chunk-vite-node-externalize.25eaf4e5.js} +13 -13
- package/dist/{chunk-vite-node-utils.3cb38009.js → chunk-vite-node-utils.20782527.js} +26 -10
- package/dist/cli.js +6 -6
- package/dist/entry.js +7 -7
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -5
- package/dist/node.d.ts +15 -10
- package/dist/node.js +7 -7
- package/dist/spy.js +1 -1
- package/dist/{vendor-entry.a660e61c.js → vendor-entry.b20b007c.js} +144 -50
- package/dist/worker.js +14 -15
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-utils.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-utils.20782527.js';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -9,11 +9,11 @@ import require$$2 from 'events';
|
|
|
9
9
|
import require$$1 from 'https';
|
|
10
10
|
import require$$2$1 from 'http';
|
|
11
11
|
import url from 'url';
|
|
12
|
-
import { A as API_PATH } from './chunk-constants.
|
|
13
|
-
import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.
|
|
12
|
+
import { A as API_PATH } from './chunk-constants.0567483c.js';
|
|
13
|
+
import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.f25e8f44.js';
|
|
14
14
|
import 'module';
|
|
15
15
|
import 'vm';
|
|
16
|
-
import './chunk-utils-global.
|
|
16
|
+
import './chunk-utils-global.a5a8641f.js';
|
|
17
17
|
import 'tty';
|
|
18
18
|
import 'local-pkg';
|
|
19
19
|
import 'path';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import {
|
|
2
|
+
import { h as resolve } from './chunk-utils-global.a5a8641f.js';
|
|
3
3
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
5
|
const defaultPort = 51204;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
|
-
import { t as toArray,
|
|
4
|
+
import { t as toArray, h as resolve } from './chunk-utils-global.a5a8641f.js';
|
|
5
5
|
|
|
6
6
|
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
7
7
|
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
|
|
@@ -119,7 +119,7 @@ async function reportCoverage(ctx) {
|
|
|
119
119
|
})
|
|
120
120
|
};
|
|
121
121
|
}));
|
|
122
|
-
const offset =
|
|
122
|
+
const offset = 224;
|
|
123
123
|
report._getSourceMap = (coverage) => {
|
|
124
124
|
const path = pathToFileURL(coverage.url).href;
|
|
125
125
|
const data = sourceMapMeta[path];
|
package/dist/{chunk-integrations-globals.6bdc721a.js → chunk-integrations-globals.a37b2801.js}
RENAMED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { g as globalApis } from './chunk-constants.
|
|
2
|
-
import { i as index } from './vendor-entry.
|
|
1
|
+
import { g as globalApis } from './chunk-constants.0567483c.js';
|
|
2
|
+
import { i as index } from './vendor-entry.b20b007c.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './chunk-utils-global.
|
|
4
|
+
import './chunk-utils-global.a5a8641f.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'console';
|
|
10
10
|
import 'stream';
|
|
11
|
-
import './chunk-runtime-chain.
|
|
11
|
+
import './chunk-runtime-chain.37b69607.js';
|
|
12
12
|
import 'chai';
|
|
13
13
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
14
|
-
import './chunk-runtime-rpc.
|
|
15
|
-
import './chunk-utils-timers.
|
|
16
|
-
import './chunk-integrations-spy.
|
|
14
|
+
import './chunk-runtime-rpc.63398738.js';
|
|
15
|
+
import './chunk-utils-timers.f25e8f44.js';
|
|
16
|
+
import './chunk-integrations-spy.bee66426.js';
|
|
17
17
|
import 'tinyspy';
|
|
18
18
|
import 'util';
|
|
19
|
-
import './chunk-defaults.
|
|
19
|
+
import './chunk-defaults.23b3ae8a.js';
|
|
20
20
|
import 'module';
|
|
21
21
|
import 'crypto';
|
|
22
22
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import chai$1, { expect as expect$1, util } from 'chai';
|
|
2
2
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
3
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
4
|
-
import { i as isObject,
|
|
3
|
+
import { r as rpc } from './chunk-runtime-rpc.63398738.js';
|
|
4
|
+
import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.a5a8641f.js';
|
|
5
5
|
import fs, { promises } from 'fs';
|
|
6
|
-
import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.
|
|
7
|
-
import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.
|
|
6
|
+
import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.f25e8f44.js';
|
|
7
|
+
import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.bee66426.js';
|
|
8
8
|
import require$$0, { format } from 'util';
|
|
9
9
|
|
|
10
10
|
var __defProp$4 = Object.defineProperty;
|
|
@@ -517,7 +517,7 @@ function printBacktickString(str) {
|
|
|
517
517
|
}
|
|
518
518
|
function ensureDirectoryExists(filePath) {
|
|
519
519
|
try {
|
|
520
|
-
fs.mkdirSync(
|
|
520
|
+
fs.mkdirSync(join(dirname(filePath)), { recursive: true });
|
|
521
521
|
} catch {
|
|
522
522
|
}
|
|
523
523
|
}
|
|
@@ -1058,15 +1058,15 @@ if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
|
|
|
1058
1058
|
expectedAssertionsNumber: null,
|
|
1059
1059
|
expectedAssertionsNumberErrorGen: null
|
|
1060
1060
|
};
|
|
1061
|
-
Object.defineProperty(
|
|
1061
|
+
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
|
1062
1062
|
value: {
|
|
1063
1063
|
state: defaultState
|
|
1064
1064
|
}
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
|
-
const getState = () =>
|
|
1067
|
+
const getState = () => globalThis[MATCHERS_OBJECT].state;
|
|
1068
1068
|
const setState = (state) => {
|
|
1069
|
-
Object.assign(
|
|
1069
|
+
Object.assign(globalThis[MATCHERS_OBJECT].state, state);
|
|
1070
1070
|
};
|
|
1071
1071
|
const JestChaiExpect = (chai, utils) => {
|
|
1072
1072
|
function def(name, fn) {
|
|
@@ -4778,9 +4778,11 @@ class VitestUtils {
|
|
|
4778
4778
|
return this;
|
|
4779
4779
|
}
|
|
4780
4780
|
stubGlobal(name, value) {
|
|
4781
|
-
globalThis
|
|
4782
|
-
if (globalThis.window)
|
|
4781
|
+
if (globalThis.window) {
|
|
4783
4782
|
globalThis.window[name] = value;
|
|
4783
|
+
} else {
|
|
4784
|
+
globalThis[name] = value;
|
|
4785
|
+
}
|
|
4784
4786
|
return this;
|
|
4785
4787
|
}
|
|
4786
4788
|
resetModules() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
1
|
+
import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.20782527.js';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
|
-
import {
|
|
3
|
+
import { a as getWorkerState, C as isWindows, D as mergeSlashes, d as dirname, f as basename, h as resolve, E as getType, F as getAllProperties, s as slash } from './chunk-utils-global.a5a8641f.js';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
|
5
|
-
import { d as distDir } from './chunk-constants.
|
|
5
|
+
import { d as distDir } from './chunk-constants.0567483c.js';
|
|
6
6
|
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -177,6 +177,7 @@ const _VitestMocker = class {
|
|
|
177
177
|
await this.ensureSpy();
|
|
178
178
|
await this.resolveMocks();
|
|
179
179
|
const mock = this.getDependencyMock(dep);
|
|
180
|
+
const callstack = this.request.callstack;
|
|
180
181
|
if (mock === null) {
|
|
181
182
|
const cacheName = `${dep}__mock`;
|
|
182
183
|
const cache = this.moduleCache.get(cacheName);
|
|
@@ -188,9 +189,11 @@ const _VitestMocker = class {
|
|
|
188
189
|
this.emit("mocked", cacheName, { exports });
|
|
189
190
|
return exports;
|
|
190
191
|
}
|
|
191
|
-
if (typeof mock === "function")
|
|
192
|
+
if (typeof mock === "function" && !callstack.includes(`mock:${dep}`)) {
|
|
193
|
+
callstack.push(`mock:${dep}`);
|
|
192
194
|
return this.callFunctionMock(dep, mock);
|
|
193
|
-
|
|
195
|
+
}
|
|
196
|
+
if (typeof mock === "string" && !callstack.includes(mock))
|
|
194
197
|
dep = mock;
|
|
195
198
|
return this.request(dep);
|
|
196
199
|
}
|
|
@@ -224,6 +227,7 @@ class VitestRunner extends ViteNodeRunner {
|
|
|
224
227
|
}
|
|
225
228
|
prepareContext(context) {
|
|
226
229
|
const request = context.__vite_ssr_import__;
|
|
230
|
+
const resolveId = context.__vitest_resolve_id__;
|
|
227
231
|
const mocker = this.mocker.withRequest(request);
|
|
228
232
|
mocker.on("mocked", (dep, module) => {
|
|
229
233
|
this.moduleCache.set(dep, module);
|
|
@@ -233,8 +237,8 @@ class VitestRunner extends ViteNodeRunner {
|
|
|
233
237
|
Object.defineProperty(context.__vite_ssr_import_meta__, "vitest", { get: () => globalThis.__vitest_index__ });
|
|
234
238
|
}
|
|
235
239
|
return Object.assign(context, {
|
|
236
|
-
__vite_ssr_import__: (dep) => mocker.requestWithMock(dep),
|
|
237
|
-
__vite_ssr_dynamic_import__: (dep) => mocker.requestWithMock(dep),
|
|
240
|
+
__vite_ssr_import__: async (dep) => mocker.requestWithMock(await resolveId(dep)),
|
|
241
|
+
__vite_ssr_dynamic_import__: async (dep) => mocker.requestWithMock(await resolveId(dep)),
|
|
238
242
|
__vitest_mocker__: mocker
|
|
239
243
|
});
|
|
240
244
|
}
|
|
@@ -242,9 +242,9 @@ const _path = /*#__PURE__*/Object.freeze({
|
|
|
242
242
|
parse: parse
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
({
|
|
246
246
|
..._path
|
|
247
|
-
};
|
|
247
|
+
});
|
|
248
248
|
|
|
249
249
|
function getWorkerState() {
|
|
250
250
|
return globalThis.__vitest_worker__;
|
|
@@ -457,4 +457,4 @@ function getCallLastIndex(code) {
|
|
|
457
457
|
return null;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
export {
|
|
460
|
+
export { stdout as A, extname as B, isWindows as C, mergeSlashes as D, getType as E, getAllProperties as F, clone as G, partitionSuiteChildren as H, hasTests as I, getWorkerState as a, getNames as b, assertTypes as c, dirname as d, notNullish as e, basename as f, getCallLastIndex as g, resolve as h, isObject as i, join as j, isAbsolute as k, relative as l, getTests as m, noop as n, getFullName as o, picocolors as p, hasFailed as q, resetModules as r, slash as s, toArray as t, hasFailedSnapshot as u, getSuites as v, normalize as w, deepMerge as x, toNamespacedPath as y, ensurePackageInstalled as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.
|
|
1
|
+
import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.a5a8641f.js';
|
|
2
2
|
|
|
3
3
|
const setTimeout$1 = globalThis.setTimeout;
|
|
4
4
|
const setInterval = globalThis.setInterval;
|
|
@@ -7407,7 +7407,7 @@ function stringify(object, maxDepth = 10, options) {
|
|
|
7407
7407
|
const printReceived = (object) => RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)));
|
|
7408
7408
|
const printExpected = (value) => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)));
|
|
7409
7409
|
function diff(a, b, options) {
|
|
7410
|
-
return unifiedDiff(stringify(
|
|
7410
|
+
return unifiedDiff(stringify(b), stringify(a));
|
|
7411
7411
|
}
|
|
7412
7412
|
|
|
7413
7413
|
var matcherUtils = /*#__PURE__*/Object.freeze({
|
package/dist/{chunk-vite-node-externalize.92c54acc.js → chunk-vite-node-externalize.25eaf4e5.js}
RENAMED
|
@@ -5,25 +5,25 @@ import process$1 from 'process';
|
|
|
5
5
|
import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.40be925a.js';
|
|
6
6
|
import url, { fileURLToPath, pathToFileURL } from 'url';
|
|
7
7
|
import require$$0, { constants as constants$5, cpus, hostname } from 'os';
|
|
8
|
-
import { j as join, f as basename,
|
|
8
|
+
import { j as join, f as basename, d as dirname, h as resolve, p as picocolors, s as slash$2, k as isAbsolute, l as relative, m as getTests, o as getFullName, q as hasFailed, u as hasFailedSnapshot, v as getSuites, t as toArray, w as normalize, n as noop$1, x as deepMerge, y as toNamespacedPath, g as getCallLastIndex, e as notNullish, z as ensurePackageInstalled, A as stdout } from './chunk-utils-global.a5a8641f.js';
|
|
9
9
|
import { createServer, mergeConfig } from 'vite';
|
|
10
10
|
import fs$8, { promises, existsSync, readFileSync } 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.0567483c.js';
|
|
12
12
|
import readline from 'readline';
|
|
13
13
|
import require$$0$1 from 'util';
|
|
14
14
|
import require$$0$2 from 'stream';
|
|
15
15
|
import require$$2 from 'events';
|
|
16
16
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
17
|
-
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.
|
|
18
|
-
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.
|
|
17
|
+
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.20782527.js';
|
|
18
|
+
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.23b3ae8a.js';
|
|
19
19
|
import { MessageChannel } from 'worker_threads';
|
|
20
20
|
import { Tinypool } from 'tinypool';
|
|
21
21
|
import { performance } from 'perf_hooks';
|
|
22
|
-
import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.
|
|
22
|
+
import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.f25e8f44.js';
|
|
23
23
|
import MagicString from './chunk-magic-string.d5e0e473.js';
|
|
24
24
|
import { p as prompts } from './vendor-index.405e58ef.js';
|
|
25
25
|
|
|
26
|
-
var version = "0.
|
|
26
|
+
var version = "0.12.0";
|
|
27
27
|
|
|
28
28
|
function stripFinalNewline(input) {
|
|
29
29
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
@@ -8487,7 +8487,7 @@ class BaseReporter {
|
|
|
8487
8487
|
if (errors.length) {
|
|
8488
8488
|
process.exitCode = 1;
|
|
8489
8489
|
const errorMessage = picocolors.exports.red(picocolors.exports.bold(`
|
|
8490
|
-
Vitest
|
|
8490
|
+
Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run. This might cause false positive tests.
|
|
8491
8491
|
Please, resolve all the errors to make sure your tests are not affected.`));
|
|
8492
8492
|
this.ctx.log(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Unhandled Errors ")))));
|
|
8493
8493
|
this.ctx.log(errorMessage);
|
|
@@ -9838,10 +9838,10 @@ const ReportersMap = {
|
|
|
9838
9838
|
"junit": JUnitReporter
|
|
9839
9839
|
};
|
|
9840
9840
|
|
|
9841
|
-
async function loadCustomReporterModule(path,
|
|
9841
|
+
async function loadCustomReporterModule(path, runner) {
|
|
9842
9842
|
let customReporterModule;
|
|
9843
9843
|
try {
|
|
9844
|
-
customReporterModule = await
|
|
9844
|
+
customReporterModule = await runner.executeId(path);
|
|
9845
9845
|
} catch (customReporterModuleError) {
|
|
9846
9846
|
throw new Error(`Failed to load custom Reporter from ${path}`, { cause: customReporterModuleError });
|
|
9847
9847
|
}
|
|
@@ -9849,14 +9849,14 @@ async function loadCustomReporterModule(path, fetchModule) {
|
|
|
9849
9849
|
throw new Error(`Custom reporter loaded from ${path} was not the default export`);
|
|
9850
9850
|
return customReporterModule.default;
|
|
9851
9851
|
}
|
|
9852
|
-
function createReporters(reporterReferences,
|
|
9852
|
+
function createReporters(reporterReferences, runner) {
|
|
9853
9853
|
const promisedReporters = reporterReferences.map(async (referenceOrInstance) => {
|
|
9854
9854
|
if (typeof referenceOrInstance === "string") {
|
|
9855
9855
|
if (referenceOrInstance in ReportersMap) {
|
|
9856
9856
|
const BuiltinReporter = ReportersMap[referenceOrInstance];
|
|
9857
9857
|
return new BuiltinReporter();
|
|
9858
9858
|
} else {
|
|
9859
|
-
const CustomReporter = await loadCustomReporterModule(referenceOrInstance,
|
|
9859
|
+
const CustomReporter = await loadCustomReporterModule(referenceOrInstance, runner);
|
|
9860
9860
|
return new CustomReporter();
|
|
9861
9861
|
}
|
|
9862
9862
|
}
|
|
@@ -10310,7 +10310,7 @@ class Vitest {
|
|
|
10310
10310
|
return node.resolveId(id, importer);
|
|
10311
10311
|
}
|
|
10312
10312
|
});
|
|
10313
|
-
this.reporters = await createReporters(resolved.reporters, this.runner
|
|
10313
|
+
this.reporters = await createReporters(resolved.reporters, this.runner);
|
|
10314
10314
|
this.runningPromise = void 0;
|
|
10315
10315
|
this._onRestartListeners.forEach((fn) => fn());
|
|
10316
10316
|
if (resolved.coverage.enabled)
|
|
@@ -10938,7 +10938,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10938
10938
|
await ctx.setServer(options, server);
|
|
10939
10939
|
haveStarted = true;
|
|
10940
10940
|
if (options.api && options.watch)
|
|
10941
|
-
(await import('./chunk-api-setup.
|
|
10941
|
+
(await import('./chunk-api-setup.87a943bf.js')).setup(ctx);
|
|
10942
10942
|
if (!options.watch)
|
|
10943
10943
|
await server.watcher.close();
|
|
10944
10944
|
}
|
|
@@ -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 { k as isAbsolute$2, h as resolve, j as join$2, B as extname$2, d as dirname$2 } from './chunk-utils-global.a5a8641f.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
|
|
7
7
|
import assert from 'assert';
|
|
@@ -8945,15 +8945,11 @@ class ViteNodeRunner {
|
|
|
8945
8945
|
async directRequest(id, fsPath, _callstack) {
|
|
8946
8946
|
const callstack = [..._callstack, normalizeModuleId(id)];
|
|
8947
8947
|
const request = async (dep) => {
|
|
8948
|
-
var _a
|
|
8948
|
+
var _a;
|
|
8949
8949
|
const getStack = () => {
|
|
8950
8950
|
return `stack:
|
|
8951
8951
|
${[...callstack, dep].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
8952
8952
|
};
|
|
8953
|
-
if (this.options.resolveId && this.shouldResolveId(dep)) {
|
|
8954
|
-
const resolvedDep = await this.options.resolveId(dep, id);
|
|
8955
|
-
dep = ((_a = resolvedDep == null ? void 0 : resolvedDep.id) == null ? void 0 : _a.replace(this.root, "")) || dep;
|
|
8956
|
-
}
|
|
8957
8953
|
let debugTimer;
|
|
8958
8954
|
if (this.debug)
|
|
8959
8955
|
debugTimer = setTimeout(() => this.debugLog(() => `module ${dep} takes over 2s to load.
|
|
@@ -8961,7 +8957,7 @@ ${getStack()}`), 2e3);
|
|
|
8961
8957
|
try {
|
|
8962
8958
|
if (callstack.includes(normalizeModuleId(dep))) {
|
|
8963
8959
|
this.debugLog(() => `circular dependency, ${getStack()}`);
|
|
8964
|
-
const depExports = (
|
|
8960
|
+
const depExports = (_a = this.moduleCache.get(dep)) == null ? void 0 : _a.exports;
|
|
8965
8961
|
if (depExports)
|
|
8966
8962
|
return depExports;
|
|
8967
8963
|
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
@@ -8973,10 +8969,22 @@ ${getStack()}`), 2e3);
|
|
|
8973
8969
|
clearTimeout(debugTimer);
|
|
8974
8970
|
}
|
|
8975
8971
|
};
|
|
8972
|
+
Object.defineProperty(request, "callstack", { get: () => callstack });
|
|
8973
|
+
const resolveId = async (dep, callstackPosition = 1) => {
|
|
8974
|
+
if (this.options.resolveId && this.shouldResolveId(dep)) {
|
|
8975
|
+
let importer = callstack[callstack.length - callstackPosition];
|
|
8976
|
+
if (importer && importer.startsWith("mock:"))
|
|
8977
|
+
importer = importer.slice(5);
|
|
8978
|
+
const { id: id2 } = await this.options.resolveId(dep, importer) || {};
|
|
8979
|
+
dep = id2 && isAbsolute$2(id2) ? `/@fs/${id2}` : id2 || dep;
|
|
8980
|
+
}
|
|
8981
|
+
return dep;
|
|
8982
|
+
};
|
|
8983
|
+
id = await resolveId(id, 2);
|
|
8976
8984
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
8977
8985
|
if (id in requestStubs)
|
|
8978
8986
|
return requestStubs[id];
|
|
8979
|
-
|
|
8987
|
+
let { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
8980
8988
|
if (externalize) {
|
|
8981
8989
|
const mod = await this.interopedImport(externalize);
|
|
8982
8990
|
this.moduleCache.set(fsPath, { exports: mod });
|
|
@@ -8998,18 +9006,26 @@ ${getStack()}`), 2e3);
|
|
|
8998
9006
|
return exports.default;
|
|
8999
9007
|
}
|
|
9000
9008
|
};
|
|
9009
|
+
let require;
|
|
9001
9010
|
const context = this.prepareContext({
|
|
9002
9011
|
__vite_ssr_import__: request,
|
|
9003
9012
|
__vite_ssr_dynamic_import__: request,
|
|
9004
9013
|
__vite_ssr_exports__: exports,
|
|
9005
9014
|
__vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
|
|
9006
9015
|
__vite_ssr_import_meta__: { url },
|
|
9007
|
-
|
|
9016
|
+
__vitest_resolve_id__: resolveId,
|
|
9017
|
+
require: (path) => {
|
|
9018
|
+
if (!require)
|
|
9019
|
+
require = createRequire(url);
|
|
9020
|
+
return require(path);
|
|
9021
|
+
},
|
|
9008
9022
|
exports,
|
|
9009
9023
|
module: moduleProxy,
|
|
9010
9024
|
__filename,
|
|
9011
9025
|
__dirname: dirname$2(__filename)
|
|
9012
9026
|
});
|
|
9027
|
+
if (transformed[0] === "#")
|
|
9028
|
+
transformed = transformed.replace(/^\#\!.*/, (s) => " ".repeat(s.length));
|
|
9013
9029
|
const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(",")})=>{{${transformed}
|
|
9014
9030
|
}}`, {
|
|
9015
9031
|
filename: fsPath,
|
|
@@ -9022,7 +9038,7 @@ ${getStack()}`), 2e3);
|
|
|
9022
9038
|
return context;
|
|
9023
9039
|
}
|
|
9024
9040
|
shouldResolveId(dep) {
|
|
9025
|
-
if (isNodeBuiltin(dep) || dep in (this.options.requestStubs || DEFAULT_REQUEST_STUBS))
|
|
9041
|
+
if (isNodeBuiltin(dep) || dep in (this.options.requestStubs || DEFAULT_REQUEST_STUBS) || dep.startsWith("/@vite"))
|
|
9026
9042
|
return false;
|
|
9027
9043
|
return !isAbsolute$2(dep) || !extname$2(dep);
|
|
9028
9044
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { p as picocolors } from './chunk-utils-global.
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
2
|
+
import { p as picocolors } from './chunk-utils-global.a5a8641f.js';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.25eaf4e5.js';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
@@ -16,16 +16,16 @@ import 'util';
|
|
|
16
16
|
import 'url';
|
|
17
17
|
import 'os';
|
|
18
18
|
import 'vite';
|
|
19
|
-
import './chunk-constants.
|
|
19
|
+
import './chunk-constants.0567483c.js';
|
|
20
20
|
import 'readline';
|
|
21
|
-
import './chunk-vite-node-utils.
|
|
21
|
+
import './chunk-vite-node-utils.20782527.js';
|
|
22
22
|
import 'module';
|
|
23
23
|
import 'vm';
|
|
24
|
-
import './chunk-defaults.
|
|
24
|
+
import './chunk-defaults.23b3ae8a.js';
|
|
25
25
|
import 'worker_threads';
|
|
26
26
|
import 'tinypool';
|
|
27
27
|
import 'perf_hooks';
|
|
28
|
-
import './chunk-utils-timers.
|
|
28
|
+
import './chunk-utils-timers.f25e8f44.js';
|
|
29
29
|
import './chunk-magic-string.d5e0e473.js';
|
|
30
30
|
import './vendor-index.405e58ef.js';
|
|
31
31
|
|
package/dist/entry.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { r as run } from './vendor-entry.
|
|
1
|
+
export { r as run } from './vendor-entry.b20b007c.js';
|
|
2
2
|
import 'fs';
|
|
3
|
-
import './chunk-utils-global.
|
|
3
|
+
import './chunk-utils-global.a5a8641f.js';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
7
7
|
import 'console';
|
|
8
8
|
import 'stream';
|
|
9
|
-
import './chunk-runtime-chain.
|
|
9
|
+
import './chunk-runtime-chain.37b69607.js';
|
|
10
10
|
import 'chai';
|
|
11
11
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
12
|
-
import './chunk-runtime-rpc.
|
|
13
|
-
import './chunk-utils-timers.
|
|
14
|
-
import './chunk-integrations-spy.
|
|
12
|
+
import './chunk-runtime-rpc.63398738.js';
|
|
13
|
+
import './chunk-utils-timers.f25e8f44.js';
|
|
14
|
+
import './chunk-integrations-spy.bee66426.js';
|
|
15
15
|
import 'tinyspy';
|
|
16
16
|
import 'util';
|
|
17
|
-
import './chunk-defaults.
|
|
17
|
+
import './chunk-defaults.23b3ae8a.js';
|
|
18
18
|
import 'module';
|
|
19
19
|
import 'url';
|
|
20
20
|
import 'crypto';
|
package/dist/index.d.ts
CHANGED
|
@@ -636,6 +636,7 @@ interface C8Options {
|
|
|
636
636
|
skipFull?: boolean;
|
|
637
637
|
extension?: string | string[];
|
|
638
638
|
all?: boolean;
|
|
639
|
+
src?: string[];
|
|
639
640
|
100?: boolean;
|
|
640
641
|
lines?: number;
|
|
641
642
|
functions?: number;
|
|
@@ -1153,6 +1154,14 @@ interface InlineConfig {
|
|
|
1153
1154
|
* Resolve custom snapshot path
|
|
1154
1155
|
*/
|
|
1155
1156
|
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
1157
|
+
/**
|
|
1158
|
+
* Pass with no tests
|
|
1159
|
+
*/
|
|
1160
|
+
passWithNoTests?: boolean;
|
|
1161
|
+
/**
|
|
1162
|
+
* Allow tests and suites that are marked as only
|
|
1163
|
+
*/
|
|
1164
|
+
allowOnly?: boolean;
|
|
1156
1165
|
/**
|
|
1157
1166
|
* Show heap usage after each test. Usefull for debugging memory leaks.
|
|
1158
1167
|
*/
|
|
@@ -1173,14 +1182,6 @@ interface UserConfig extends InlineConfig {
|
|
|
1173
1182
|
* Use happy-dom
|
|
1174
1183
|
*/
|
|
1175
1184
|
dom?: boolean;
|
|
1176
|
-
/**
|
|
1177
|
-
* Pass with no tests
|
|
1178
|
-
*/
|
|
1179
|
-
passWithNoTests?: boolean;
|
|
1180
|
-
/**
|
|
1181
|
-
* Allow tests and suites that are marked as only
|
|
1182
|
-
*/
|
|
1183
|
-
allowOnly?: boolean;
|
|
1184
1185
|
/**
|
|
1185
1186
|
* Run tests that cover a list of source files
|
|
1186
1187
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.
|
|
1
|
+
export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.37b69607.js';
|
|
2
2
|
export { assert, default as chai, should } from 'chai';
|
|
3
3
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
4
|
-
import './chunk-runtime-rpc.
|
|
5
|
-
import './chunk-utils-global.
|
|
4
|
+
import './chunk-runtime-rpc.63398738.js';
|
|
5
|
+
import './chunk-utils-global.a5a8641f.js';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
8
|
import 'path';
|
|
9
9
|
import 'fs';
|
|
10
|
-
import './chunk-utils-timers.
|
|
11
|
-
import './chunk-integrations-spy.
|
|
10
|
+
import './chunk-utils-timers.f25e8f44.js';
|
|
11
|
+
import './chunk-integrations-spy.bee66426.js';
|
|
12
12
|
import 'tinyspy';
|
|
13
13
|
import 'util';
|
package/dist/node.d.ts
CHANGED
|
@@ -405,6 +405,7 @@ interface C8Options {
|
|
|
405
405
|
skipFull?: boolean;
|
|
406
406
|
extension?: string | string[];
|
|
407
407
|
all?: boolean;
|
|
408
|
+
src?: string[];
|
|
408
409
|
100?: boolean;
|
|
409
410
|
lines?: number;
|
|
410
411
|
functions?: number;
|
|
@@ -854,6 +855,14 @@ interface InlineConfig {
|
|
|
854
855
|
* Resolve custom snapshot path
|
|
855
856
|
*/
|
|
856
857
|
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
858
|
+
/**
|
|
859
|
+
* Pass with no tests
|
|
860
|
+
*/
|
|
861
|
+
passWithNoTests?: boolean;
|
|
862
|
+
/**
|
|
863
|
+
* Allow tests and suites that are marked as only
|
|
864
|
+
*/
|
|
865
|
+
allowOnly?: boolean;
|
|
857
866
|
/**
|
|
858
867
|
* Show heap usage after each test. Usefull for debugging memory leaks.
|
|
859
868
|
*/
|
|
@@ -874,14 +883,6 @@ interface UserConfig extends InlineConfig {
|
|
|
874
883
|
* Use happy-dom
|
|
875
884
|
*/
|
|
876
885
|
dom?: boolean;
|
|
877
|
-
/**
|
|
878
|
-
* Pass with no tests
|
|
879
|
-
*/
|
|
880
|
-
passWithNoTests?: boolean;
|
|
881
|
-
/**
|
|
882
|
-
* Allow tests and suites that are marked as only
|
|
883
|
-
*/
|
|
884
|
-
allowOnly?: boolean;
|
|
885
886
|
/**
|
|
886
887
|
* Run tests that cover a list of source files
|
|
887
888
|
*/
|
|
@@ -1016,6 +1017,10 @@ interface CliOptions extends UserConfig {
|
|
|
1016
1017
|
declare function startVitest(cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
|
|
1017
1018
|
|
|
1018
1019
|
declare type Callback = (...args: any[]) => unknown;
|
|
1020
|
+
interface ViteRunnerRequest {
|
|
1021
|
+
(dep: string): any;
|
|
1022
|
+
callstack: string[];
|
|
1023
|
+
}
|
|
1019
1024
|
declare class VitestMocker {
|
|
1020
1025
|
options: ExecuteOptions;
|
|
1021
1026
|
private moduleCache;
|
|
@@ -1024,7 +1029,7 @@ declare class VitestMocker {
|
|
|
1024
1029
|
private request;
|
|
1025
1030
|
private root;
|
|
1026
1031
|
private callbacks;
|
|
1027
|
-
constructor(options: ExecuteOptions, moduleCache: ModuleCacheMap, request?:
|
|
1032
|
+
constructor(options: ExecuteOptions, moduleCache: ModuleCacheMap, request?: ViteRunnerRequest);
|
|
1028
1033
|
get mockMap(): MockMap;
|
|
1029
1034
|
on(event: string, cb: Callback): void;
|
|
1030
1035
|
private emit;
|
|
@@ -1049,7 +1054,7 @@ declare class VitestMocker {
|
|
|
1049
1054
|
requestWithMock(dep: string): Promise<any>;
|
|
1050
1055
|
queueMock(id: string, importer: string, factory?: () => unknown): void;
|
|
1051
1056
|
queueUnmock(id: string, importer: string): void;
|
|
1052
|
-
withRequest(request:
|
|
1057
|
+
withRequest(request: ViteRunnerRequest): VitestMocker;
|
|
1053
1058
|
}
|
|
1054
1059
|
|
|
1055
1060
|
interface ExecuteOptions extends ViteNodeRunnerOptions {
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.25eaf4e5.js';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.ee72d19a.js';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'child_process';
|
|
@@ -13,19 +13,19 @@ import 'stream';
|
|
|
13
13
|
import 'util';
|
|
14
14
|
import 'url';
|
|
15
15
|
import 'os';
|
|
16
|
-
import './chunk-utils-global.
|
|
16
|
+
import './chunk-utils-global.a5a8641f.js';
|
|
17
17
|
import 'tty';
|
|
18
18
|
import 'local-pkg';
|
|
19
19
|
import 'vite';
|
|
20
|
-
import './chunk-constants.
|
|
20
|
+
import './chunk-constants.0567483c.js';
|
|
21
21
|
import 'readline';
|
|
22
|
-
import './chunk-vite-node-utils.
|
|
22
|
+
import './chunk-vite-node-utils.20782527.js';
|
|
23
23
|
import 'module';
|
|
24
24
|
import 'vm';
|
|
25
|
-
import './chunk-defaults.
|
|
25
|
+
import './chunk-defaults.23b3ae8a.js';
|
|
26
26
|
import 'worker_threads';
|
|
27
27
|
import 'tinypool';
|
|
28
28
|
import 'perf_hooks';
|
|
29
|
-
import './chunk-utils-timers.
|
|
29
|
+
import './chunk-utils-timers.f25e8f44.js';
|
|
30
30
|
import './chunk-magic-string.d5e0e473.js';
|
|
31
31
|
import './vendor-index.405e58ef.js';
|
package/dist/spy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as fn, i as isMockFunction, a as spies, s as spyOn } from './chunk-integrations-spy.
|
|
1
|
+
export { f as fn, i as isMockFunction, a as spies, s as spyOn } from './chunk-integrations-spy.bee66426.js';
|
|
2
2
|
import 'tinyspy';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import {
|
|
2
|
+
import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative, A as stdout, H as partitionSuiteChildren, I as hasTests, q as hasFailed, o as getFullName, r as resetModules } from './chunk-utils-global.a5a8641f.js';
|
|
3
3
|
import { Console } from 'console';
|
|
4
4
|
import { Writable } from 'stream';
|
|
5
5
|
import { importModule } from 'local-pkg';
|
|
6
|
-
import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.
|
|
6
|
+
import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.37b69607.js';
|
|
7
7
|
import chai, { assert, should, util } from 'chai';
|
|
8
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
9
|
-
import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.
|
|
10
|
-
import { t as takeCoverage } from './chunk-defaults.
|
|
8
|
+
import { r as rpc } from './chunk-runtime-rpc.63398738.js';
|
|
9
|
+
import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.f25e8f44.js';
|
|
10
|
+
import { t as takeCoverage } from './chunk-defaults.23b3ae8a.js';
|
|
11
11
|
import { createHash } from 'crypto';
|
|
12
12
|
import { format } from 'util';
|
|
13
13
|
|
|
@@ -212,6 +212,7 @@ const OTHER_KEYS = [
|
|
|
212
212
|
"atob",
|
|
213
213
|
"blur",
|
|
214
214
|
"btoa",
|
|
215
|
+
"cancelAnimationFrame",
|
|
215
216
|
"close",
|
|
216
217
|
"confirm",
|
|
217
218
|
"createPopup",
|
|
@@ -240,6 +241,7 @@ const OTHER_KEYS = [
|
|
|
240
241
|
"print",
|
|
241
242
|
"prompt",
|
|
242
243
|
"removeEventListener",
|
|
244
|
+
"requestAnimationFrame",
|
|
243
245
|
"resizeBy",
|
|
244
246
|
"resizeTo",
|
|
245
247
|
"screen",
|
|
@@ -262,20 +264,118 @@ const OTHER_KEYS = [
|
|
|
262
264
|
];
|
|
263
265
|
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
264
266
|
|
|
265
|
-
const allowRewrite =
|
|
267
|
+
const allowRewrite = [
|
|
266
268
|
"Event",
|
|
267
269
|
"EventTarget"
|
|
268
|
-
]
|
|
270
|
+
];
|
|
271
|
+
const skipKeys = [
|
|
272
|
+
"window",
|
|
273
|
+
"self",
|
|
274
|
+
"top",
|
|
275
|
+
"parent"
|
|
276
|
+
];
|
|
269
277
|
function getWindowKeys(global, win) {
|
|
270
278
|
const keys = new Set(KEYS.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
|
271
|
-
if (k.startsWith("_"))
|
|
279
|
+
if (k.startsWith("_") || skipKeys.includes(k))
|
|
272
280
|
return false;
|
|
273
281
|
if (k in global)
|
|
274
|
-
return allowRewrite.
|
|
282
|
+
return allowRewrite.includes(k);
|
|
275
283
|
return true;
|
|
276
284
|
}));
|
|
277
285
|
return keys;
|
|
278
286
|
}
|
|
287
|
+
function populateGlobal(global, win, options = {}) {
|
|
288
|
+
const { bindFunctions = false } = options;
|
|
289
|
+
const keys = getWindowKeys(global, win);
|
|
290
|
+
const overrideObject = /* @__PURE__ */ new Map();
|
|
291
|
+
for (const key of keys) {
|
|
292
|
+
const shouldBind = bindFunctions && typeof win[key] === "function";
|
|
293
|
+
Object.defineProperty(global, key, {
|
|
294
|
+
get() {
|
|
295
|
+
if (overrideObject.has(key))
|
|
296
|
+
return overrideObject.get(key);
|
|
297
|
+
if (shouldBind)
|
|
298
|
+
return win[key].bind(win);
|
|
299
|
+
return win[key];
|
|
300
|
+
},
|
|
301
|
+
set(v) {
|
|
302
|
+
overrideObject.set(key, v);
|
|
303
|
+
},
|
|
304
|
+
configurable: true
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const globalKeys = /* @__PURE__ */ new Set(["window", "self", "top", "parent"]);
|
|
308
|
+
const globalProxy = new Proxy(win.window, {
|
|
309
|
+
get(target, p, receiver) {
|
|
310
|
+
if (overrideObject.has(p))
|
|
311
|
+
return overrideObject.get(p);
|
|
312
|
+
return Reflect.get(target, p, receiver);
|
|
313
|
+
},
|
|
314
|
+
set(target, p, value, receiver) {
|
|
315
|
+
try {
|
|
316
|
+
Object.defineProperty(global, p, {
|
|
317
|
+
get: () => overrideObject.get(p),
|
|
318
|
+
set: (value2) => overrideObject.set(p, value2),
|
|
319
|
+
configurable: true
|
|
320
|
+
});
|
|
321
|
+
overrideObject.set(p, value);
|
|
322
|
+
Reflect.set(target, p, value, receiver);
|
|
323
|
+
} catch {
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
},
|
|
327
|
+
deleteProperty(target, p) {
|
|
328
|
+
Reflect.deleteProperty(global, p);
|
|
329
|
+
overrideObject.delete(p);
|
|
330
|
+
return Reflect.deleteProperty(target, p);
|
|
331
|
+
},
|
|
332
|
+
defineProperty(target, p, attributes) {
|
|
333
|
+
if (attributes.writable && "value" in attributes) ; else if (attributes.get) {
|
|
334
|
+
overrideObject.delete(p);
|
|
335
|
+
Reflect.defineProperty(global, p, attributes);
|
|
336
|
+
}
|
|
337
|
+
return Reflect.defineProperty(target, p, attributes);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
globalKeys.forEach((key) => {
|
|
341
|
+
if (!win[key])
|
|
342
|
+
return;
|
|
343
|
+
Object.defineProperty(global, key, {
|
|
344
|
+
get() {
|
|
345
|
+
return globalProxy;
|
|
346
|
+
},
|
|
347
|
+
configurable: true
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
const globalThisProxy = new Proxy(global.globalThis, {
|
|
351
|
+
set(target, key, value, receiver) {
|
|
352
|
+
overrideObject.set(key, value);
|
|
353
|
+
return Reflect.set(target, key, value, receiver);
|
|
354
|
+
},
|
|
355
|
+
deleteProperty(target, key) {
|
|
356
|
+
overrideObject.delete(key);
|
|
357
|
+
return Reflect.deleteProperty(target, key);
|
|
358
|
+
},
|
|
359
|
+
defineProperty(target, p, attributes) {
|
|
360
|
+
if (attributes.writable && "value" in attributes) ; else if (attributes.get && !globalKeys.has(p)) {
|
|
361
|
+
globalKeys.forEach((key) => {
|
|
362
|
+
if (win[key])
|
|
363
|
+
Object.defineProperty(win[key], p, attributes);
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
return Reflect.defineProperty(target, p, attributes);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
global.globalThis = globalThisProxy;
|
|
370
|
+
if (global.global)
|
|
371
|
+
global.global = globalThisProxy;
|
|
372
|
+
skipKeys.forEach((k) => keys.add(k));
|
|
373
|
+
return {
|
|
374
|
+
keys,
|
|
375
|
+
skipKeys,
|
|
376
|
+
allowRewrite
|
|
377
|
+
};
|
|
378
|
+
}
|
|
279
379
|
|
|
280
380
|
var __defProp$1 = Object.defineProperty;
|
|
281
381
|
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
@@ -348,24 +448,12 @@ var jsdom = {
|
|
|
348
448
|
contentType,
|
|
349
449
|
userAgent
|
|
350
450
|
}, restOptions));
|
|
351
|
-
const keys =
|
|
352
|
-
const
|
|
353
|
-
for (const key of keys) {
|
|
354
|
-
Object.defineProperty(global, key, {
|
|
355
|
-
get() {
|
|
356
|
-
if (overrideObject.has(key))
|
|
357
|
-
return overrideObject.get(key);
|
|
358
|
-
return dom.window[key];
|
|
359
|
-
},
|
|
360
|
-
set(v) {
|
|
361
|
-
overrideObject.set(key, v);
|
|
362
|
-
},
|
|
363
|
-
configurable: true
|
|
364
|
-
});
|
|
365
|
-
}
|
|
451
|
+
const { keys, allowRewrite } = populateGlobal(global, dom.window);
|
|
452
|
+
const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
|
|
366
453
|
return {
|
|
367
454
|
teardown(global2) {
|
|
368
455
|
keys.forEach((key) => delete global2[key]);
|
|
456
|
+
originals.forEach((v, k) => global2[k] = v);
|
|
369
457
|
}
|
|
370
458
|
};
|
|
371
459
|
}
|
|
@@ -376,25 +464,13 @@ var happy = {
|
|
|
376
464
|
async setup(global) {
|
|
377
465
|
const { Window, GlobalWindow } = await importModule("happy-dom");
|
|
378
466
|
const win = new (GlobalWindow || Window)();
|
|
379
|
-
const keys =
|
|
380
|
-
const
|
|
381
|
-
for (const key of keys) {
|
|
382
|
-
Object.defineProperty(global, key, {
|
|
383
|
-
get() {
|
|
384
|
-
if (overrideObject.has(key))
|
|
385
|
-
return overrideObject.get(key);
|
|
386
|
-
return win[key];
|
|
387
|
-
},
|
|
388
|
-
set(v) {
|
|
389
|
-
overrideObject.set(key, v);
|
|
390
|
-
},
|
|
391
|
-
configurable: true
|
|
392
|
-
});
|
|
393
|
-
}
|
|
467
|
+
const { keys, allowRewrite } = populateGlobal(global, win, { bindFunctions: true });
|
|
468
|
+
const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
|
|
394
469
|
return {
|
|
395
470
|
teardown(global2) {
|
|
396
471
|
win.happyDOM.cancelAsync();
|
|
397
472
|
keys.forEach((key) => delete global2[key]);
|
|
473
|
+
originals.forEach((v, k) => global2[k] = v);
|
|
398
474
|
}
|
|
399
475
|
};
|
|
400
476
|
}
|
|
@@ -419,7 +495,7 @@ async function setupGlobalEnv(config) {
|
|
|
419
495
|
globalSetup = true;
|
|
420
496
|
setupConsoleLogSpy();
|
|
421
497
|
if (config.globals)
|
|
422
|
-
(await import('./chunk-integrations-globals.
|
|
498
|
+
(await import('./chunk-integrations-globals.a37b2801.js')).registerApiGlobally();
|
|
423
499
|
}
|
|
424
500
|
function setupDefines(defines) {
|
|
425
501
|
for (const key in defines)
|
|
@@ -970,21 +1046,39 @@ function clearModuleMocks() {
|
|
|
970
1046
|
}
|
|
971
1047
|
|
|
972
1048
|
async function run(files, config) {
|
|
973
|
-
var _a;
|
|
974
1049
|
await setupGlobalEnv(config);
|
|
975
1050
|
const workerState = getWorkerState();
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1051
|
+
const envs = ["node", "jsdom", "happy-dom"];
|
|
1052
|
+
const filesWithEnv = await Promise.all(files.map(async (file) => {
|
|
1053
|
+
var _a;
|
|
979
1054
|
const code = await promises.readFile(file, "utf-8");
|
|
980
1055
|
const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
|
|
981
|
-
if (!
|
|
982
|
-
throw new Error(`Unsupported environment: ${env}`);
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1056
|
+
if (!envs.includes(env))
|
|
1057
|
+
throw new Error(`Unsupported environment: "${env}" in ${file}`);
|
|
1058
|
+
return {
|
|
1059
|
+
file,
|
|
1060
|
+
env
|
|
1061
|
+
};
|
|
1062
|
+
}));
|
|
1063
|
+
const filesByEnv = filesWithEnv.reduce((acc, { file, env }) => {
|
|
1064
|
+
acc[env] || (acc[env] = []);
|
|
1065
|
+
acc[env].push(file);
|
|
1066
|
+
return acc;
|
|
1067
|
+
}, {});
|
|
1068
|
+
for (const env of envs) {
|
|
1069
|
+
const environment = env;
|
|
1070
|
+
const files2 = filesByEnv[environment];
|
|
1071
|
+
if (!files2 || !files2.length)
|
|
1072
|
+
continue;
|
|
1073
|
+
await withEnv(environment, config.environmentOptions || {}, async () => {
|
|
1074
|
+
for (const file of files2) {
|
|
1075
|
+
workerState.mockMap.clear();
|
|
1076
|
+
resetModules();
|
|
1077
|
+
workerState.filepath = file;
|
|
1078
|
+
await startTests([file], config);
|
|
1079
|
+
workerState.filepath = void 0;
|
|
1080
|
+
}
|
|
986
1081
|
});
|
|
987
|
-
workerState.filepath = void 0;
|
|
988
1082
|
}
|
|
989
1083
|
}
|
|
990
1084
|
|
package/dist/worker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.
|
|
3
|
-
import { d as distDir } from './chunk-constants.
|
|
4
|
-
import { e as executeInViteNode } from './chunk-runtime-mocker.
|
|
5
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
1
|
+
import { h as resolve, a as getWorkerState, A as stdout } from './chunk-utils-global.a5a8641f.js';
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.20782527.js';
|
|
3
|
+
import { d as distDir } from './chunk-constants.0567483c.js';
|
|
4
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.ee72d19a.js';
|
|
5
|
+
import { r as rpc } from './chunk-runtime-rpc.63398738.js';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
8
|
import 'path';
|
|
@@ -32,7 +32,7 @@ async function startViteNode(ctx) {
|
|
|
32
32
|
rpc().onUnhandledRejection(err);
|
|
33
33
|
});
|
|
34
34
|
const { config } = ctx;
|
|
35
|
-
const { run: run2
|
|
35
|
+
const { run: run2 } = (await executeInViteNode({
|
|
36
36
|
files: [
|
|
37
37
|
resolve(distDir, "entry.js")
|
|
38
38
|
],
|
|
@@ -48,7 +48,7 @@ async function startViteNode(ctx) {
|
|
|
48
48
|
root: config.root,
|
|
49
49
|
base: config.base
|
|
50
50
|
}))[0];
|
|
51
|
-
_viteNode = { run: run2
|
|
51
|
+
_viteNode = { run: run2 };
|
|
52
52
|
return _viteNode;
|
|
53
53
|
}
|
|
54
54
|
function init(ctx) {
|
|
@@ -72,19 +72,18 @@ function init(ctx) {
|
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
};
|
|
75
|
-
if (ctx.invalidates)
|
|
76
|
-
ctx.invalidates.forEach((i) =>
|
|
75
|
+
if (ctx.invalidates) {
|
|
76
|
+
ctx.invalidates.forEach((i) => {
|
|
77
|
+
moduleCache.delete(i);
|
|
78
|
+
moduleCache.delete(`${i}__mock`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
77
81
|
ctx.files.forEach((i) => moduleCache.delete(i));
|
|
78
82
|
}
|
|
79
|
-
async function collect(ctx) {
|
|
80
|
-
init(ctx);
|
|
81
|
-
const { collect: collect2 } = await startViteNode(ctx);
|
|
82
|
-
return collect2(ctx.files, ctx.config);
|
|
83
|
-
}
|
|
84
83
|
async function run(ctx) {
|
|
85
84
|
init(ctx);
|
|
86
85
|
const { run: run2 } = await startViteNode(ctx);
|
|
87
86
|
return run2(ctx.files, ctx.config);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
export {
|
|
89
|
+
export { run };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.0",
|
|
5
5
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vite",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@types/node": "^17.0.31",
|
|
94
94
|
"@types/prompts": "^2.4.0",
|
|
95
95
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
96
|
-
"@vitest/ui": "0.
|
|
96
|
+
"@vitest/ui": "0.12.0",
|
|
97
97
|
"birpc": "^0.2.2",
|
|
98
98
|
"c8": "^7.11.2",
|
|
99
99
|
"cac": "^6.7.12",
|
|
@@ -116,11 +116,11 @@
|
|
|
116
116
|
"pkg-types": "^0.3.2",
|
|
117
117
|
"pretty-format": "^27.5.1",
|
|
118
118
|
"prompts": "^2.4.2",
|
|
119
|
-
"rollup": "^2.
|
|
119
|
+
"rollup": "^2.72.1",
|
|
120
120
|
"source-map-js": "^1.0.2",
|
|
121
121
|
"strip-ansi": "^7.0.1",
|
|
122
122
|
"typescript": "^4.6.4",
|
|
123
|
-
"vite-node": "0.
|
|
123
|
+
"vite-node": "0.12.0",
|
|
124
124
|
"ws": "^8.6.0"
|
|
125
125
|
},
|
|
126
126
|
"engines": {
|