vitest 1.1.3 → 1.2.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/browser.d.ts +1 -1
- package/dist/browser.js +5 -31
- package/dist/chunks/{api-setup.mFKdEKxa.js → api-setup.MAoRkVWJ.js} +60 -6
- package/dist/chunks/{integrations-globals.tnKXwyh5.js → integrations-globals.VbxbZ7hn.js} +9 -8
- package/dist/{entry.js → chunks/runtime-runBaseTests.LWFmrzDk.js} +20 -18
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +14 -14
- package/dist/config.cjs +12 -1
- package/dist/config.d.ts +5 -2
- package/dist/config.js +12 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +8 -6
- package/dist/execute.js +4 -7
- package/dist/index.d.ts +4 -3
- package/dist/index.js +8 -7
- package/dist/node.d.ts +3 -3
- package/dist/node.js +12 -12
- package/dist/{reporters-qc5Smpt5.d.ts → reporters-trlZlObr.d.ts} +111 -27
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +7 -5
- package/dist/{suite-WwpgKT7k.d.ts → suite-6Pt_ep5V.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +3 -3
- package/dist/vendor/base.8wUUWReP.js +38 -0
- package/dist/vendor/{base._79unx2z.js → base.dzu0Y6Hj.js} +10 -1
- package/dist/vendor/{benchmark.WVm6DARl.js → benchmark.IlKmJkUU.js} +1 -1
- package/dist/vendor/{constants.WSvnD_fn.js → constants.i1PoEnhr.js} +9 -1
- package/dist/vendor/{coverage.v6aD8iAh.js → coverage.E7sG1b3r.js} +1 -1
- package/dist/vendor/{environments.QJtma9XQ.js → environments.sU0TD7wX.js} +19 -7
- package/dist/vendor/execute.3_hyGknJ.js +589 -0
- package/dist/vendor/{global.L7JRz1qU.js → global.CkGT_TMy.js} +10 -1
- package/dist/vendor/{index.IhksUGLR.js → index.3iX2R_Z5.js} +6 -6
- package/dist/vendor/{index.h0j9y5vy.js → index.D-jOsMas.js} +5 -5
- package/dist/vendor/{index.XU72Rmy8.js → index.rJjbcrrp.js} +1 -1
- package/dist/vendor/{node.wTZytysZ.js → node.xyYo9ZvH.js} +650 -274
- package/dist/vendor/{reporters.7Y4WN6gc.js → reporters.2PaQ2peU.js} +7 -4
- package/dist/vendor/{rpc.Bl-ysZIr.js → rpc.w4v8oCkK.js} +23 -2
- package/dist/vendor/{run-once.X3E7xx3F.js → run-once.Olz_Zkd8.js} +2 -2
- package/dist/vendor/setup-common.j9IXYrbN.js +29 -0
- package/dist/vendor/utils.GbToHGHI.js +41 -0
- package/dist/vendor/{vi.DTC--YO5.js → vi.smj1Ggd4.js} +9 -5
- package/dist/vendor/vm.vFKXXdo0.js +696 -0
- package/dist/worker.js +109 -82
- package/dist/workers/forks.js +33 -0
- package/dist/{entry-vm.js → workers/runVmTests.js} +20 -16
- package/dist/workers/threads.js +26 -0
- package/dist/workers/vmForks.js +43 -0
- package/dist/workers/vmThreads.js +36 -0
- package/dist/workers.d.ts +36 -0
- package/dist/workers.js +30 -0
- package/package.json +11 -7
- package/workers.d.ts +1 -0
- package/dist/child.js +0 -125
- package/dist/vendor/execute.cedv4NLQ.js +0 -1235
- package/dist/vendor/inspector.lFAeuaAt.js +0 -26
- package/dist/vendor/loader.L9CYwKn1.js +0 -39
- package/dist/vm.js +0 -126
- /package/dist/{paths.js → path.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import c from 'picocolors';
|
|
3
|
-
import { b as isNode, c as relativePath } from './index.
|
|
3
|
+
import { b as isNode, c as relativePath } from './index.rJjbcrrp.js';
|
|
4
4
|
import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.hf2msWA9.js';
|
|
5
5
|
import { isAbsolute, relative, dirname, basename, resolve } from 'pathe';
|
|
6
|
-
import {
|
|
6
|
+
import { b as slash, t as toArray } from './base.dzu0Y6Hj.js';
|
|
7
7
|
import { g as getFullName, h as hasFailedSnapshot } from './tasks.IknbGB2n.js';
|
|
8
8
|
import { getSafeTimers, notNullish } from '@vitest/utils';
|
|
9
9
|
import { isCI } from 'std-env';
|
|
@@ -2005,6 +2005,8 @@ class VerboseReporter extends DefaultReporter {
|
|
|
2005
2005
|
if ((_c = task.suite) == null ? void 0 : _c.projectName)
|
|
2006
2006
|
title += formatProjectName(task.suite.projectName);
|
|
2007
2007
|
title += getFullName(task, c.dim(" > "));
|
|
2008
|
+
if (task.result.duration != null && task.result.duration > this.ctx.config.slowTestThreshold)
|
|
2009
|
+
title += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
2008
2010
|
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
2009
2011
|
title += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
2010
2012
|
this.ctx.logger.log(title);
|
|
@@ -2059,8 +2061,9 @@ class TapReporter {
|
|
|
2059
2061
|
return "";
|
|
2060
2062
|
}
|
|
2061
2063
|
logErrorDetails(error, stack) {
|
|
2062
|
-
|
|
2063
|
-
this.logger.log(`
|
|
2064
|
+
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
2065
|
+
this.logger.log(`name: ${yamlString(String(errorName))}`);
|
|
2066
|
+
this.logger.log(`message: ${yamlString(String(error.message))}`);
|
|
2064
2067
|
if (stack) {
|
|
2065
2068
|
this.logger.log(`stack: ${yamlString(`${stack.file}:${stack.line}:${stack.column}`)}`);
|
|
2066
2069
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSafeTimers } from '@vitest/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { c as createBirpc } from './index.cAUulNDf.js';
|
|
3
|
+
import { g as getWorkerState } from './global.CkGT_TMy.js';
|
|
3
4
|
|
|
4
5
|
const { get } = Reflect;
|
|
5
6
|
function withSafeTimers(fn) {
|
|
@@ -38,6 +39,26 @@ async function rpcDone() {
|
|
|
38
39
|
const awaitable = Array.from(promises);
|
|
39
40
|
return Promise.all(awaitable);
|
|
40
41
|
}
|
|
42
|
+
function createRuntimeRpc(options) {
|
|
43
|
+
let setCancel = (_reason) => {
|
|
44
|
+
};
|
|
45
|
+
const onCancel = new Promise((resolve) => {
|
|
46
|
+
setCancel = resolve;
|
|
47
|
+
});
|
|
48
|
+
const rpc2 = createSafeRpc(createBirpc(
|
|
49
|
+
{
|
|
50
|
+
onCancel: setCancel
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onCancel"],
|
|
54
|
+
...options
|
|
55
|
+
}
|
|
56
|
+
));
|
|
57
|
+
return {
|
|
58
|
+
rpc: rpc2,
|
|
59
|
+
onCancel
|
|
60
|
+
};
|
|
61
|
+
}
|
|
41
62
|
function createSafeRpc(rpc2) {
|
|
42
63
|
return new Proxy(rpc2, {
|
|
43
64
|
get(target, p, handler) {
|
|
@@ -61,4 +82,4 @@ function rpc() {
|
|
|
61
82
|
return rpc2;
|
|
62
83
|
}
|
|
63
84
|
|
|
64
|
-
export {
|
|
85
|
+
export { rpcDone as a, createRuntimeRpc as c, rpc as r };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getWorkerState } from './global.
|
|
1
|
+
import { g as getWorkerState } from './global.CkGT_TMy.js';
|
|
2
2
|
|
|
3
3
|
const filesCount = /* @__PURE__ */ new Map();
|
|
4
4
|
const cache = /* @__PURE__ */ new Map();
|
|
@@ -24,4 +24,4 @@ function resetRunOnceCounter() {
|
|
|
24
24
|
filesCount.clear();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export {
|
|
27
|
+
export { runOnce as a, isFirstRun as i, resetRunOnceCounter as r };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { setSafeTimers } from '@vitest/utils';
|
|
2
|
+
import { r as resetRunOnceCounter } from './run-once.Olz_Zkd8.js';
|
|
3
|
+
|
|
4
|
+
let globalSetup = false;
|
|
5
|
+
async function setupCommonEnv(config) {
|
|
6
|
+
resetRunOnceCounter();
|
|
7
|
+
setupDefines(config.defines);
|
|
8
|
+
if (globalSetup)
|
|
9
|
+
return;
|
|
10
|
+
globalSetup = true;
|
|
11
|
+
setSafeTimers();
|
|
12
|
+
if (config.globals)
|
|
13
|
+
(await import('../chunks/integrations-globals.VbxbZ7hn.js')).registerApiGlobally();
|
|
14
|
+
}
|
|
15
|
+
function setupDefines(defines) {
|
|
16
|
+
for (const key in defines)
|
|
17
|
+
globalThis[key] = defines[key];
|
|
18
|
+
}
|
|
19
|
+
async function loadDiffConfig(config, executor) {
|
|
20
|
+
if (typeof config.diff !== "string")
|
|
21
|
+
return;
|
|
22
|
+
const diffModule = await executor.executeId(config.diff);
|
|
23
|
+
if (diffModule && typeof diffModule.default === "object" && diffModule.default != null)
|
|
24
|
+
return diffModule.default;
|
|
25
|
+
else
|
|
26
|
+
throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { loadDiffConfig as l, setupCommonEnv as s };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseRegexp } from '@vitest/utils';
|
|
2
|
+
|
|
3
|
+
function createThreadsRpcOptions({ port }) {
|
|
4
|
+
return {
|
|
5
|
+
post: (v) => {
|
|
6
|
+
port.postMessage(v);
|
|
7
|
+
},
|
|
8
|
+
on: (fn) => {
|
|
9
|
+
port.addListener("message", fn);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function createForksRpcOptions(nodeV8) {
|
|
14
|
+
return {
|
|
15
|
+
serialize: nodeV8.serialize,
|
|
16
|
+
deserialize: (v) => nodeV8.deserialize(Buffer.from(v)),
|
|
17
|
+
post(v) {
|
|
18
|
+
process.send(v);
|
|
19
|
+
},
|
|
20
|
+
on(fn) {
|
|
21
|
+
process.on("message", (message, ...extras) => {
|
|
22
|
+
if (message == null ? void 0 : message.__tinypool_worker_message__)
|
|
23
|
+
return;
|
|
24
|
+
return fn(message, ...extras);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function parsePossibleRegexp(str) {
|
|
30
|
+
const prefix = "$$vitest:";
|
|
31
|
+
if (typeof str === "string" && str.startsWith(prefix))
|
|
32
|
+
return parseRegexp(str.slice(prefix.length));
|
|
33
|
+
return str;
|
|
34
|
+
}
|
|
35
|
+
function unwrapForksConfig(config) {
|
|
36
|
+
if (config.testNamePattern)
|
|
37
|
+
config.testNamePattern = parsePossibleRegexp(config.testNamePattern);
|
|
38
|
+
return config;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { createThreadsRpcOptions as a, createForksRpcOptions as c, unwrapForksConfig as u };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as chai$1 from 'chai';
|
|
2
2
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.jjO7Zipk.js';
|
|
3
|
-
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT as GLOBAL_EXPECT$1, ASYMMETRIC_MATCHERS_OBJECT as ASYMMETRIC_MATCHERS_OBJECT$1, getState, setState } from '@vitest/expect';
|
|
3
|
+
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT as GLOBAL_EXPECT$1, ASYMMETRIC_MATCHERS_OBJECT as ASYMMETRIC_MATCHERS_OBJECT$1, getState, setState, addCustomEqualityTesters } from '@vitest/expect';
|
|
4
4
|
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
|
|
5
5
|
import { getNames } from '@vitest/runner/utils';
|
|
6
6
|
import '@vitest/utils/error';
|
|
7
7
|
import { getCurrentTest } from '@vitest/runner';
|
|
8
8
|
import { g as getFullName } from './tasks.IknbGB2n.js';
|
|
9
|
-
import { g as getWorkerState, a as getCurrentEnvironment } from './global.
|
|
9
|
+
import { g as getWorkerState, a as getCurrentEnvironment } from './global.CkGT_TMy.js';
|
|
10
10
|
import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
|
|
11
11
|
import { parseSingleStack } from '@vitest/utils/source-map';
|
|
12
|
+
import { i as isChildProcess } from './base.dzu0Y6Hj.js';
|
|
12
13
|
import { R as RealDate, r as resetDate, m as mockDate } from './date.Ns1pGd_X.js';
|
|
13
14
|
import { spyOn, fn, isMockFunction, mocks } from '@vitest/spy';
|
|
14
15
|
|
|
@@ -149,6 +150,7 @@ const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for("asymmetric-matchers-object");
|
|
|
149
150
|
if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
150
151
|
const globalState = /* @__PURE__ */ new WeakMap();
|
|
151
152
|
const matchers = /* @__PURE__ */ Object.create(null);
|
|
153
|
+
const customEqualityTesters = [];
|
|
152
154
|
const assymetricMatchers = /* @__PURE__ */ Object.create(null);
|
|
153
155
|
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
|
154
156
|
get: () => globalState
|
|
@@ -157,7 +159,8 @@ if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
|
|
|
157
159
|
configurable: true,
|
|
158
160
|
get: () => ({
|
|
159
161
|
state: globalState.get(globalThis[GLOBAL_EXPECT]),
|
|
160
|
-
matchers
|
|
162
|
+
matchers,
|
|
163
|
+
customEqualityTesters
|
|
161
164
|
})
|
|
162
165
|
});
|
|
163
166
|
Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, {
|
|
@@ -372,6 +375,7 @@ function createExpect(test) {
|
|
|
372
375
|
currentTestName: test ? getFullName(test) : globalState.currentTestName
|
|
373
376
|
}, expect);
|
|
374
377
|
expect.extend = (matchers) => chai$1.expect.extend(expect, matchers);
|
|
378
|
+
expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
|
375
379
|
expect.soft = (...args) => {
|
|
376
380
|
const assert2 = expect(...args);
|
|
377
381
|
expect.setState({
|
|
@@ -3122,7 +3126,7 @@ class FakeTimers {
|
|
|
3122
3126
|
}
|
|
3123
3127
|
if (!this._fakingTime) {
|
|
3124
3128
|
const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick");
|
|
3125
|
-
if (((_b = (_a = this._userConfig) == null ? void 0 : _a.toFake) == null ? void 0 : _b.includes("nextTick")) &&
|
|
3129
|
+
if (((_b = (_a = this._userConfig) == null ? void 0 : _a.toFake) == null ? void 0 : _b.includes("nextTick")) && isChildProcess())
|
|
3126
3130
|
throw new Error("process.nextTick cannot be mocked inside child_process");
|
|
3127
3131
|
this._clock = this._fakeTimers.install({
|
|
3128
3132
|
now: Date.now(),
|
|
@@ -3315,7 +3319,7 @@ function createVitest() {
|
|
|
3315
3319
|
const utils = {
|
|
3316
3320
|
useFakeTimers(config) {
|
|
3317
3321
|
var _a, _b, _c, _d;
|
|
3318
|
-
if (
|
|
3322
|
+
if (isChildProcess()) {
|
|
3319
3323
|
if (((_a = config == null ? void 0 : config.toFake) == null ? void 0 : _a.includes("nextTick")) || ((_d = (_c = (_b = workerState.config) == null ? void 0 : _b.fakeTimers) == null ? void 0 : _c.toFake) == null ? void 0 : _d.includes("nextTick"))) {
|
|
3320
3324
|
throw new Error(
|
|
3321
3325
|
'vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.'
|