vitest 2.0.0-beta.3 → 2.0.0-beta.6
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/browser.d.ts +5 -1
- package/dist/browser.js +18 -2
- package/dist/chunks/{integrations-globals.D0I8wu4f.js → integrations-globals.BK0Cn4q1.js} +3 -4
- package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.DiVMr5d4.js} +54 -24
- package/dist/chunks/{runtime-runBaseTests.CsxVA4nP.js → runtime-runBaseTests.C-Bkopka.js} +5 -6
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +1 -1
- package/dist/index-Bp1kcIfF.d.ts +1571 -0
- package/dist/index.d.ts +6 -1448
- package/dist/index.js +3 -4
- package/dist/node.d.ts +2 -6
- package/dist/node.js +6 -6
- package/dist/{reporters-C-3dxOaA.d.ts → reporters-qky6mwBH.d.ts} +237 -91
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +2 -1
- package/dist/runners.js +6 -1
- package/dist/{suite-V5kCKZme.d.ts → suite-B5_jYIf8.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/vendor/{base.CfOCwoIE.js → base.D4XK-wRp.js} +2 -2
- package/dist/vendor/{cac.f5m2SesE.js → cac.DDQuPgBf.js} +47 -16
- package/dist/vendor/{cli-api.pZNNj7LX.js → cli-api.C0OPqjkb.js} +372 -200
- package/dist/vendor/{constants.XmjJgDXx.js → constants.TCjCaw2D.js} +2 -1
- package/dist/vendor/{execute.Bwzklsfj.js → execute.BHj6OMh4.js} +2 -2
- package/dist/vendor/{index.DOAUPIJU.js → index.CyGfDRbW.js} +34 -14
- package/dist/vendor/{index.BHPXakMe.js → index.DHRpy7zp.js} +1 -1
- package/dist/vendor/{index.BkeKAX-R.js → index.DwR86H5i.js} +26 -3
- package/dist/vendor/{setup-common.6St9QHh1.js → setup-common.BhJvzjns.js} +2 -2
- package/dist/vendor/{utils.D5gGkwyH.js → utils.YuQ3LT2a.js} +1 -1
- package/dist/vendor/{vi.B31D70yH.js → vi.C6AfDXK6.js} +23 -11
- package/dist/vendor/{vm.rKHnSoLJ.js → vm.Ow-X2mkS.js} +2 -2
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +4 -5
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +3 -3
- package/dist/workers/vmThreads.js +3 -3
- package/dist/workers.d.ts +1 -1
- package/dist/workers.js +4 -4
- package/package.json +9 -9
- package/dist/vendor/run-once.DLomgGUH.js +0 -27
|
@@ -3,6 +3,7 @@ const defaultBrowserPort = 63315;
|
|
|
3
3
|
const defaultInspectPort = 9229;
|
|
4
4
|
const EXIT_CODE_RESTART = 43;
|
|
5
5
|
const API_PATH = "/__vitest_api__";
|
|
6
|
+
const BROWSER_API_PATH = "/__vitest_browser_api__";
|
|
6
7
|
const extraInlineDeps = [
|
|
7
8
|
/^(?!.*node_modules).*\.mjs$/,
|
|
8
9
|
/^(?!.*node_modules).*\.cjs\.js$/,
|
|
@@ -62,4 +63,4 @@ const globalApis = [
|
|
|
62
63
|
"onTestFailed"
|
|
63
64
|
];
|
|
64
65
|
|
|
65
|
-
export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
66
|
+
export { API_PATH as A, BROWSER_API_PATH as B, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
@@ -68,7 +68,7 @@ class VitestMocker {
|
|
|
68
68
|
if (this.moduleCache.has(mockId))
|
|
69
69
|
this.moduleCache.delete(mockId);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
isModuleDirectory(path) {
|
|
72
72
|
return this.moduleDirectories.some((dir) => path.includes(dir));
|
|
73
73
|
}
|
|
74
74
|
getSuiteFilepath() {
|
|
@@ -103,7 +103,7 @@ class VitestMocker {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
const external = !isAbsolute(fsPath) || this.
|
|
106
|
+
const external = !isAbsolute(fsPath) || this.isModuleDirectory(fsPath) ? rawId : null;
|
|
107
107
|
return {
|
|
108
108
|
id,
|
|
109
109
|
fsPath,
|
|
@@ -5,14 +5,14 @@ import { basename, dirname, resolve, join, relative, extname, normalize } from '
|
|
|
5
5
|
import { a as getFullName, h as hasFailedSnapshot } from './tasks.WC7M-K-v.js';
|
|
6
6
|
import { getSafeTimers, notNullish, highlight, shuffle, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
|
|
7
7
|
import { i as isNode } from './env.bmJgw1qP.js';
|
|
8
|
-
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, r as renderSnapshotSummary,
|
|
8
|
+
import { g as getStateSymbol, f as formatProjectName, p as pointer, F as F_RIGHT, a as F_POINTER, r as renderSnapshotSummary, b as getStateString, c as formatTimeString, d as countTestErrors, e as divider, s as stripAnsi, h as getCols, i as getHookStateSymbol } from './utils.YuQ3LT2a.js';
|
|
9
9
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getTests, hasFailed, getSuites } from '@vitest/runner/utils';
|
|
10
10
|
import { performance } from 'node:perf_hooks';
|
|
11
|
+
import { TraceMap, generatedPositionFor, parseStacktrace, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
11
12
|
import { r as relativePath } from './index._7XLd8Kd.js';
|
|
12
|
-
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.
|
|
13
|
+
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.DiVMr5d4.js';
|
|
13
14
|
import { t as toArray, b as isPrimitive } from './base._gnK9Slw.js';
|
|
14
15
|
import { isCI } from 'std-env';
|
|
15
|
-
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
16
16
|
import nodeos__default, { hostname } from 'node:os';
|
|
17
17
|
import { Writable } from 'node:stream';
|
|
18
18
|
import { writeFile, rm, mkdir, readdir, readFile } from 'node:fs/promises';
|
|
@@ -1143,9 +1143,26 @@ ${PROJECT_FILTER}${FILENAME_PATTERN}${TESTNAME_PATTERN}`);
|
|
|
1143
1143
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
1144
1144
|
const header = c.gray(log.type + c.dim(` | ${task ? getFullName(task, c.dim(" > ")) : log.taskId !== UNKNOWN_TEST_ID ? log.taskId : "unknown test"}`));
|
|
1145
1145
|
const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream;
|
|
1146
|
-
output.write(
|
|
1147
|
-
|
|
1148
|
-
`);
|
|
1146
|
+
const write = (msg) => output.write(msg);
|
|
1147
|
+
write(`${header}
|
|
1148
|
+
${log.content}`);
|
|
1149
|
+
if (log.origin) {
|
|
1150
|
+
if (log.browser)
|
|
1151
|
+
write("\n");
|
|
1152
|
+
const project = log.taskId ? this.ctx.getProjectByTaskId(log.taskId) : this.ctx.getCoreWorkspaceProject();
|
|
1153
|
+
const stack = parseStacktrace(log.origin, {
|
|
1154
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
1155
|
+
frameFilter: project.config.onStackTrace
|
|
1156
|
+
});
|
|
1157
|
+
const highlight = task ? stack.find((i) => i.file === task.file.filepath) : null;
|
|
1158
|
+
for (const frame of stack) {
|
|
1159
|
+
const color = frame === highlight ? c.cyan : c.gray;
|
|
1160
|
+
const path = relative(project.config.root, frame.file);
|
|
1161
|
+
write(color(` ${c.dim(F_POINTER)} ${[frame.method, `${path}:${c.dim(`${frame.line}:${frame.column}`)}`].filter(Boolean).join(" ")}
|
|
1162
|
+
`));
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
write("\n");
|
|
1149
1166
|
}
|
|
1150
1167
|
shouldLog(log) {
|
|
1151
1168
|
var _a, _b;
|
|
@@ -1295,8 +1312,8 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1295
1312
|
const hasStr = ((_a2 = i[0]) == null ? void 0 : _a2.stackStr) === error.stackStr;
|
|
1296
1313
|
if (!hasStr)
|
|
1297
1314
|
return false;
|
|
1298
|
-
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName);
|
|
1299
|
-
const projectName = ((_c2 = i[1][0]) == null ? void 0 : _c2.projectName) || ((_d = i[1][0].file) == null ? void 0 : _d.projectName);
|
|
1315
|
+
const currentProjectName = (task == null ? void 0 : task.projectName) || ((_b2 = task.file) == null ? void 0 : _b2.projectName) || "";
|
|
1316
|
+
const projectName = ((_c2 = i[1][0]) == null ? void 0 : _c2.projectName) || ((_d = i[1][0].file) == null ? void 0 : _d.projectName) || "";
|
|
1300
1317
|
return projectName === currentProjectName;
|
|
1301
1318
|
});
|
|
1302
1319
|
if (errorItem)
|
|
@@ -1308,7 +1325,7 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
|
1308
1325
|
for (const [error, tasks2] of errorsQueue) {
|
|
1309
1326
|
for (const task of tasks2) {
|
|
1310
1327
|
const filepath = (task == null ? void 0 : task.filepath) || "";
|
|
1311
|
-
const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName);
|
|
1328
|
+
const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName) || "";
|
|
1312
1329
|
let name = getFullName(task, c.dim(" > "));
|
|
1313
1330
|
if (filepath)
|
|
1314
1331
|
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
@@ -4887,7 +4904,7 @@ class BlobReporter {
|
|
|
4887
4904
|
throw new Error("Blob reporter is not supported in watch mode");
|
|
4888
4905
|
this.ctx = ctx;
|
|
4889
4906
|
}
|
|
4890
|
-
async onFinished(files = [], errors = []) {
|
|
4907
|
+
async onFinished(files = [], errors = [], coverage) {
|
|
4891
4908
|
let outputFile = this.options.outputFile ?? getOutputFile(this.ctx.config, "blob");
|
|
4892
4909
|
if (!outputFile) {
|
|
4893
4910
|
const shard = this.ctx.config.shard;
|
|
@@ -4896,7 +4913,7 @@ class BlobReporter {
|
|
|
4896
4913
|
const moduleKeys = this.ctx.projects.map((project) => {
|
|
4897
4914
|
return [project.getName(), [...project.server.moduleGraph.idToModuleMap.keys()]];
|
|
4898
4915
|
});
|
|
4899
|
-
const report = stringify([this.ctx.version, files, errors, moduleKeys]);
|
|
4916
|
+
const report = stringify([this.ctx.version, files, errors, moduleKeys, coverage]);
|
|
4900
4917
|
const reportFile = resolve(this.ctx.config.root, outputFile);
|
|
4901
4918
|
const dir = dirname(reportFile);
|
|
4902
4919
|
if (!existsSync(dir))
|
|
@@ -4914,8 +4931,8 @@ async function readBlobs(blobsDirectory, projectsArray) {
|
|
|
4914
4931
|
const blobsFiles = await readdir(resolvedDir);
|
|
4915
4932
|
const promises = blobsFiles.map(async (file) => {
|
|
4916
4933
|
const content = await readFile(resolve(resolvedDir, file), "utf-8");
|
|
4917
|
-
const [version, files2, errors2, moduleKeys] = parse(content);
|
|
4918
|
-
return { version, files: files2, errors: errors2, moduleKeys };
|
|
4934
|
+
const [version, files2, errors2, moduleKeys, coverage] = parse(content);
|
|
4935
|
+
return { version, files: files2, errors: errors2, moduleKeys, coverage };
|
|
4919
4936
|
});
|
|
4920
4937
|
const blobs = await Promise.all(promises);
|
|
4921
4938
|
if (!blobs.length)
|
|
@@ -4956,9 +4973,11 @@ async function readBlobs(blobsDirectory, projectsArray) {
|
|
|
4956
4973
|
return time1 - time2;
|
|
4957
4974
|
});
|
|
4958
4975
|
const errors = blobs.flatMap((blob) => blob.errors);
|
|
4976
|
+
const coverages = blobs.map((blob) => blob.coverage);
|
|
4959
4977
|
return {
|
|
4960
4978
|
files,
|
|
4961
|
-
errors
|
|
4979
|
+
errors,
|
|
4980
|
+
coverages
|
|
4962
4981
|
};
|
|
4963
4982
|
}
|
|
4964
4983
|
|
|
@@ -5274,6 +5293,7 @@ function createFormattedBenchamrkReport(files) {
|
|
|
5274
5293
|
benchmarks.push({
|
|
5275
5294
|
id: t.id,
|
|
5276
5295
|
sampleCount: samples.length,
|
|
5296
|
+
median: samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2,
|
|
5277
5297
|
...rest
|
|
5278
5298
|
});
|
|
5279
5299
|
}
|
|
@@ -4,7 +4,7 @@ import { distDir } from '../path.js';
|
|
|
4
4
|
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
5
5
|
import { r as rpc } from './rpc.DRDE9Pu1.js';
|
|
6
6
|
import { t as takeCoverageInsideWorker } from './coverage.ChSqD-qS.js';
|
|
7
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
7
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.BhJvzjns.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
10
10
|
Object.assign(chai.config, config);
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
2
|
import { b as bench } from './benchmark.BNLebNi5.js';
|
|
3
|
-
import { i as isFirstRun, a as runOnce } from './run-once.DLomgGUH.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.B31D70yH.js';
|
|
5
3
|
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.C6AfDXK6.js';
|
|
6
5
|
import * as chai from 'chai';
|
|
7
6
|
import { assert, should } from 'chai';
|
|
8
7
|
|
|
8
|
+
const filesCount = /* @__PURE__ */ new Map();
|
|
9
|
+
const cache = /* @__PURE__ */ new Map();
|
|
10
|
+
function runOnce(fn, key) {
|
|
11
|
+
const filepath = getWorkerState().filepath || "__unknown_files__";
|
|
12
|
+
if (!key) {
|
|
13
|
+
filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
|
|
14
|
+
key = String(filesCount.get(filepath));
|
|
15
|
+
}
|
|
16
|
+
const id = `${filepath}:${key}`;
|
|
17
|
+
if (!cache.has(id))
|
|
18
|
+
cache.set(id, fn());
|
|
19
|
+
return cache.get(id);
|
|
20
|
+
}
|
|
21
|
+
function isFirstRun() {
|
|
22
|
+
let firstRun = false;
|
|
23
|
+
runOnce(() => {
|
|
24
|
+
firstRun = true;
|
|
25
|
+
}, "__vitest_first_run__");
|
|
26
|
+
return firstRun;
|
|
27
|
+
}
|
|
28
|
+
function resetRunOnceCounter() {
|
|
29
|
+
filesCount.clear();
|
|
30
|
+
}
|
|
31
|
+
|
|
9
32
|
function getRunningMode() {
|
|
10
33
|
return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
|
|
11
34
|
}
|
|
@@ -128,4 +151,4 @@ var VitestIndex = /*#__PURE__*/Object.freeze({
|
|
|
128
151
|
vitest: vitest
|
|
129
152
|
});
|
|
130
153
|
|
|
131
|
-
export { VitestIndex as V,
|
|
154
|
+
export { VitestIndex as V, runOnce as a, inject as b, isWatchMode as c, dist as d, assertType as e, getRunningMode as g, isFirstRun as i, resetRunOnceCounter as r };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setSafeTimers } from '@vitest/utils';
|
|
2
2
|
import { addSerializer } from '@vitest/snapshot';
|
|
3
|
-
import { r as resetRunOnceCounter } from './
|
|
3
|
+
import { r as resetRunOnceCounter } from './index.DwR86H5i.js';
|
|
4
4
|
|
|
5
5
|
let globalSetup = false;
|
|
6
6
|
async function setupCommonEnv(config) {
|
|
@@ -12,7 +12,7 @@ async function setupCommonEnv(config) {
|
|
|
12
12
|
globalSetup = true;
|
|
13
13
|
setSafeTimers();
|
|
14
14
|
if (config.globals)
|
|
15
|
-
(await import('../chunks/integrations-globals.
|
|
15
|
+
(await import('../chunks/integrations-globals.BK0Cn4q1.js')).registerApiGlobally();
|
|
16
16
|
}
|
|
17
17
|
function setupDefines(defines) {
|
|
18
18
|
for (const key in defines)
|
|
@@ -214,4 +214,4 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
214
214
|
spinnerMap: spinnerMap
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
-
export { F_RIGHT as F,
|
|
217
|
+
export { F_RIGHT as F, F_POINTER as a, getStateString as b, formatTimeString as c, countTestErrors as d, divider as e, formatProjectName as f, getStateSymbol as g, getCols as h, getHookStateSymbol as i, pointer as p, renderSnapshotSummary as r, stripAnsi as s, utils as u };
|
|
@@ -8,6 +8,8 @@ import { getCurrentTest } from '@vitest/runner';
|
|
|
8
8
|
import { g as getTestName } from './tasks.WC7M-K-v.js';
|
|
9
9
|
import { g as getWorkerState, a as getCurrentEnvironment } from './global.7bFbnyXl.js';
|
|
10
10
|
import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
|
|
11
|
+
import 'pathe';
|
|
12
|
+
import './env.bmJgw1qP.js';
|
|
11
13
|
import { parseSingleStack } from '@vitest/utils/source-map';
|
|
12
14
|
import { i as isChildProcess } from './base._gnK9Slw.js';
|
|
13
15
|
import { R as RealDate, r as resetDate, m as mockDate } from './date.BKM1wewY.js';
|
|
@@ -355,7 +357,14 @@ const unsupported = [
|
|
|
355
357
|
];
|
|
356
358
|
function createExpectPoll(expect) {
|
|
357
359
|
return function poll(fn, options = {}) {
|
|
358
|
-
|
|
360
|
+
var _a;
|
|
361
|
+
const state = getWorkerState();
|
|
362
|
+
const defaults = ((_a = state.config.expect) == null ? void 0 : _a.poll) ?? {};
|
|
363
|
+
const {
|
|
364
|
+
interval = defaults.interval ?? 50,
|
|
365
|
+
timeout = defaults.timeout ?? 1e3,
|
|
366
|
+
message
|
|
367
|
+
} = options;
|
|
359
368
|
const assertion = expect(null, message).withContext({ poll: true });
|
|
360
369
|
const proxy = new Proxy(assertion, {
|
|
361
370
|
get(target, key, receiver) {
|
|
@@ -3382,10 +3391,13 @@ function createVitest() {
|
|
|
3382
3391
|
const _stubsGlobal = /* @__PURE__ */ new Map();
|
|
3383
3392
|
const _stubsEnv = /* @__PURE__ */ new Map();
|
|
3384
3393
|
const _envBooleans = ["PROD", "DEV", "SSR"];
|
|
3385
|
-
const getImporter = () => {
|
|
3386
|
-
const stackTrace = createSimpleStackTrace({ stackTraceLimit:
|
|
3387
|
-
const
|
|
3388
|
-
const
|
|
3394
|
+
const getImporter = (name) => {
|
|
3395
|
+
const stackTrace = createSimpleStackTrace({ stackTraceLimit: 5 });
|
|
3396
|
+
const stackArray = stackTrace.split("\n");
|
|
3397
|
+
const importerStackIndex = stackArray.findIndex((stack2) => {
|
|
3398
|
+
return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
|
|
3399
|
+
});
|
|
3400
|
+
const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
|
|
3389
3401
|
return (stack == null ? void 0 : stack.file) || "";
|
|
3390
3402
|
};
|
|
3391
3403
|
const utils = {
|
|
@@ -3480,7 +3492,7 @@ function createVitest() {
|
|
|
3480
3492
|
mock(path, factory) {
|
|
3481
3493
|
if (typeof path !== "string")
|
|
3482
3494
|
throw new Error(`vi.mock() expects a string path, but received a ${typeof path}`);
|
|
3483
|
-
const importer = getImporter();
|
|
3495
|
+
const importer = getImporter("mock");
|
|
3484
3496
|
_mocker.queueMock(
|
|
3485
3497
|
path,
|
|
3486
3498
|
importer,
|
|
@@ -3491,12 +3503,12 @@ function createVitest() {
|
|
|
3491
3503
|
unmock(path) {
|
|
3492
3504
|
if (typeof path !== "string")
|
|
3493
3505
|
throw new Error(`vi.unmock() expects a string path, but received a ${typeof path}`);
|
|
3494
|
-
_mocker.queueUnmock(path, getImporter());
|
|
3506
|
+
_mocker.queueUnmock(path, getImporter("unmock"));
|
|
3495
3507
|
},
|
|
3496
3508
|
doMock(path, factory) {
|
|
3497
3509
|
if (typeof path !== "string")
|
|
3498
3510
|
throw new Error(`vi.doMock() expects a string path, but received a ${typeof path}`);
|
|
3499
|
-
const importer = getImporter();
|
|
3511
|
+
const importer = getImporter("doMock");
|
|
3500
3512
|
_mocker.queueMock(
|
|
3501
3513
|
path,
|
|
3502
3514
|
importer,
|
|
@@ -3507,17 +3519,17 @@ function createVitest() {
|
|
|
3507
3519
|
doUnmock(path) {
|
|
3508
3520
|
if (typeof path !== "string")
|
|
3509
3521
|
throw new Error(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
|
|
3510
|
-
_mocker.queueUnmock(path, getImporter());
|
|
3522
|
+
_mocker.queueUnmock(path, getImporter("doUnmock"));
|
|
3511
3523
|
},
|
|
3512
3524
|
async importActual(path) {
|
|
3513
3525
|
return _mocker.importActual(
|
|
3514
3526
|
path,
|
|
3515
|
-
getImporter(),
|
|
3527
|
+
getImporter("importActual"),
|
|
3516
3528
|
_mocker.getMockContext().callstack
|
|
3517
3529
|
);
|
|
3518
3530
|
},
|
|
3519
3531
|
async importMock(path) {
|
|
3520
|
-
return _mocker.importMock(path, getImporter());
|
|
3532
|
+
return _mocker.importMock(path, getImporter("importMock"));
|
|
3521
3533
|
},
|
|
3522
3534
|
// this is typed in the interface so it's not necessary to type it here
|
|
3523
3535
|
mocked(item, _options = {}) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import vm, { isContext } from 'node:vm';
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
3
3
|
import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
|
|
4
|
-
import { createCustomConsole } from '../chunks/runtime-console.
|
|
5
|
-
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.
|
|
4
|
+
import { createCustomConsole } from '../chunks/runtime-console.DiVMr5d4.js';
|
|
5
|
+
import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.BHj6OMh4.js';
|
|
6
6
|
import { distDir } from '../path.js';
|
|
7
7
|
import { dirname as dirname$1 } from 'node:path';
|
|
8
8
|
import { statSync, existsSync, promises, readFileSync } from 'node:fs';
|
package/dist/workers/forks.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
2
|
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.CUjzkRH7.js';
|
|
3
|
-
import { r as runBaseTests } from '../vendor/base.
|
|
3
|
+
import { r as runBaseTests } from '../vendor/base.D4XK-wRp.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'vite-node/client';
|
|
6
6
|
import '../vendor/global.7bFbnyXl.js';
|
|
7
|
-
import '../vendor/execute.
|
|
7
|
+
import '../vendor/execute.BHj6OMh4.js';
|
|
8
8
|
import 'node:vm';
|
|
9
9
|
import 'node:url';
|
|
10
10
|
import 'node:fs';
|
|
@@ -6,11 +6,11 @@ import { performance } from 'node:perf_hooks';
|
|
|
6
6
|
import { startTests } from '@vitest/runner';
|
|
7
7
|
import { setupColors, createColors } from '@vitest/utils';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
|
-
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../vendor/index.
|
|
9
|
+
import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../vendor/index.DHRpy7zp.js';
|
|
10
10
|
import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.ChSqD-qS.js';
|
|
11
11
|
import { g as getWorkerState } from '../vendor/global.7bFbnyXl.js';
|
|
12
|
-
import { V as VitestIndex } from '../vendor/index.
|
|
13
|
-
import { s as setupCommonEnv } from '../vendor/setup-common.
|
|
12
|
+
import { V as VitestIndex } from '../vendor/index.DwR86H5i.js';
|
|
13
|
+
import { s as setupCommonEnv } from '../vendor/setup-common.BhJvzjns.js';
|
|
14
14
|
import { c as closeInspector } from '../vendor/inspector.hPQncR7V.js';
|
|
15
15
|
import 'chai';
|
|
16
16
|
import 'pathe';
|
|
@@ -23,8 +23,7 @@ import '@vitest/runner/utils';
|
|
|
23
23
|
import '../vendor/index._7XLd8Kd.js';
|
|
24
24
|
import '../vendor/env.bmJgw1qP.js';
|
|
25
25
|
import 'std-env';
|
|
26
|
-
import '../vendor/
|
|
27
|
-
import '../vendor/vi.B31D70yH.js';
|
|
26
|
+
import '../vendor/vi.C6AfDXK6.js';
|
|
28
27
|
import '../vendor/_commonjsHelpers.BFTU3MAI.js';
|
|
29
28
|
import '@vitest/expect';
|
|
30
29
|
import '@vitest/snapshot';
|
package/dist/workers/threads.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as runBaseTests } from '../vendor/base.
|
|
1
|
+
import { r as runBaseTests } from '../vendor/base.D4XK-wRp.js';
|
|
2
2
|
import { a as createThreadsRpcOptions } from '../vendor/utils.CUjzkRH7.js';
|
|
3
3
|
import 'vite-node/client';
|
|
4
4
|
import '../vendor/global.7bFbnyXl.js';
|
|
5
|
-
import '../vendor/execute.
|
|
5
|
+
import '../vendor/execute.BHj6OMh4.js';
|
|
6
6
|
import 'node:vm';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'node:fs';
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import v8 from 'node:v8';
|
|
2
2
|
import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.CUjzkRH7.js';
|
|
3
|
-
import { r as runVmTests } from '../vendor/vm.
|
|
3
|
+
import { r as runVmTests } from '../vendor/vm.Ow-X2mkS.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'node:vm';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
import 'pathe';
|
|
8
|
-
import '../chunks/runtime-console.
|
|
8
|
+
import '../chunks/runtime-console.DiVMr5d4.js';
|
|
9
9
|
import 'node:stream';
|
|
10
10
|
import 'node:console';
|
|
11
11
|
import 'node:path';
|
|
@@ -14,7 +14,7 @@ import '@vitest/runner/utils';
|
|
|
14
14
|
import '../vendor/global.7bFbnyXl.js';
|
|
15
15
|
import '../vendor/env.bmJgw1qP.js';
|
|
16
16
|
import 'std-env';
|
|
17
|
-
import '../vendor/execute.
|
|
17
|
+
import '../vendor/execute.BHj6OMh4.js';
|
|
18
18
|
import 'node:fs';
|
|
19
19
|
import 'vite-node/client';
|
|
20
20
|
import 'vite-node/utils';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as createThreadsRpcOptions } from '../vendor/utils.CUjzkRH7.js';
|
|
2
|
-
import { r as runVmTests } from '../vendor/vm.
|
|
2
|
+
import { r as runVmTests } from '../vendor/vm.Ow-X2mkS.js';
|
|
3
3
|
import '@vitest/utils';
|
|
4
4
|
import 'node:vm';
|
|
5
5
|
import 'node:url';
|
|
6
6
|
import 'pathe';
|
|
7
|
-
import '../chunks/runtime-console.
|
|
7
|
+
import '../chunks/runtime-console.DiVMr5d4.js';
|
|
8
8
|
import 'node:stream';
|
|
9
9
|
import 'node:console';
|
|
10
10
|
import 'node:path';
|
|
@@ -13,7 +13,7 @@ import '@vitest/runner/utils';
|
|
|
13
13
|
import '../vendor/global.7bFbnyXl.js';
|
|
14
14
|
import '../vendor/env.bmJgw1qP.js';
|
|
15
15
|
import 'std-env';
|
|
16
|
-
import '../vendor/execute.
|
|
16
|
+
import '../vendor/execute.BHj6OMh4.js';
|
|
17
17
|
import 'node:fs';
|
|
18
18
|
import 'vite-node/client';
|
|
19
19
|
import 'vite-node/utils';
|
package/dist/workers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v8 from 'v8';
|
|
2
|
-
import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-
|
|
2
|
+
import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-qky6mwBH.js';
|
|
3
3
|
import { Awaitable } from '@vitest/utils';
|
|
4
4
|
import 'vite';
|
|
5
5
|
import '@vitest/runner';
|
package/dist/workers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.CUjzkRH7.js';
|
|
2
2
|
export { p as provideWorkerState } from './vendor/global.7bFbnyXl.js';
|
|
3
3
|
export { run as runVitestWorker } from './worker.js';
|
|
4
|
-
export { r as runVmTests } from './vendor/vm.
|
|
5
|
-
export { r as runBaseTests } from './vendor/base.
|
|
4
|
+
export { r as runVmTests } from './vendor/vm.Ow-X2mkS.js';
|
|
5
|
+
export { r as runBaseTests } from './vendor/base.D4XK-wRp.js';
|
|
6
6
|
import '@vitest/utils';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'tinypool';
|
|
@@ -17,14 +17,14 @@ import 'node:module';
|
|
|
17
17
|
import './vendor/rpc.DRDE9Pu1.js';
|
|
18
18
|
import './vendor/index.BpSiYbpB.js';
|
|
19
19
|
import 'node:vm';
|
|
20
|
-
import './chunks/runtime-console.
|
|
20
|
+
import './chunks/runtime-console.DiVMr5d4.js';
|
|
21
21
|
import 'node:stream';
|
|
22
22
|
import 'node:path';
|
|
23
23
|
import './vendor/date.BKM1wewY.js';
|
|
24
24
|
import '@vitest/runner/utils';
|
|
25
25
|
import './vendor/env.bmJgw1qP.js';
|
|
26
26
|
import 'std-env';
|
|
27
|
-
import './vendor/execute.
|
|
27
|
+
import './vendor/execute.BHj6OMh4.js';
|
|
28
28
|
import 'vite-node/utils';
|
|
29
29
|
import '@vitest/utils/error';
|
|
30
30
|
import './path.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.6",
|
|
5
5
|
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -119,8 +119,8 @@
|
|
|
119
119
|
"@types/node": "^18.0.0 || >=20.0.0",
|
|
120
120
|
"happy-dom": "*",
|
|
121
121
|
"jsdom": "*",
|
|
122
|
-
"@vitest/browser": "2.0.0-beta.
|
|
123
|
-
"@vitest/ui": "2.0.0-beta.
|
|
122
|
+
"@vitest/browser": "2.0.0-beta.6",
|
|
123
|
+
"@vitest/ui": "2.0.0-beta.6"
|
|
124
124
|
},
|
|
125
125
|
"peerDependenciesMeta": {
|
|
126
126
|
"@edge-runtime/vm": {
|
|
@@ -154,12 +154,12 @@
|
|
|
154
154
|
"tinypool": "^0.9.0",
|
|
155
155
|
"vite": "^5.0.0",
|
|
156
156
|
"why-is-node-running": "^2.2.2",
|
|
157
|
-
"@vitest/expect": "2.0.0-beta.
|
|
158
|
-
"@vitest/
|
|
159
|
-
"@vitest/
|
|
160
|
-
"@vitest/spy": "2.0.0-beta.
|
|
161
|
-
"
|
|
162
|
-
"
|
|
157
|
+
"@vitest/expect": "2.0.0-beta.6",
|
|
158
|
+
"@vitest/runner": "2.0.0-beta.6",
|
|
159
|
+
"@vitest/snapshot": "2.0.0-beta.6",
|
|
160
|
+
"@vitest/spy": "2.0.0-beta.6",
|
|
161
|
+
"vite-node": "2.0.0-beta.6",
|
|
162
|
+
"@vitest/utils": "2.0.0-beta.6"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
165
|
"@ampproject/remapping": "^2.3.0",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
2
|
-
|
|
3
|
-
const filesCount = /* @__PURE__ */ new Map();
|
|
4
|
-
const cache = /* @__PURE__ */ new Map();
|
|
5
|
-
function runOnce(fn, key) {
|
|
6
|
-
const filepath = getWorkerState().filepath || "__unknown_files__";
|
|
7
|
-
if (!key) {
|
|
8
|
-
filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
|
|
9
|
-
key = String(filesCount.get(filepath));
|
|
10
|
-
}
|
|
11
|
-
const id = `${filepath}:${key}`;
|
|
12
|
-
if (!cache.has(id))
|
|
13
|
-
cache.set(id, fn());
|
|
14
|
-
return cache.get(id);
|
|
15
|
-
}
|
|
16
|
-
function isFirstRun() {
|
|
17
|
-
let firstRun = false;
|
|
18
|
-
runOnce(() => {
|
|
19
|
-
firstRun = true;
|
|
20
|
-
}, "__vitest_first_run__");
|
|
21
|
-
return firstRun;
|
|
22
|
-
}
|
|
23
|
-
function resetRunOnceCounter() {
|
|
24
|
-
filesCount.clear();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { runOnce as a, isFirstRun as i, resetRunOnceCounter as r };
|