vitest 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +30 -2
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +2 -1
- package/dist/chunks/{integrations-globals.J_6tnlri.js → integrations-globals.THajbSRg.js} +6 -6
- package/dist/chunks/{runtime-runBaseTests.QReNMrJA.js → runtime-runBaseTests.9RbsHRbU.js} +9 -9
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +44 -131
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/coverage.d.ts +6 -6
- package/dist/coverage.js +34 -3
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +75 -78
- package/dist/index.js +7 -7
- package/dist/node.d.ts +12 -4
- package/dist/node.js +35 -27
- package/dist/{reporters-1evA5lom.d.ts → reporters-MmQN-57K.d.ts} +177 -61
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +20 -6
- package/dist/runners.d.ts +6 -6
- package/dist/runners.js +10 -10
- package/dist/{suite-ghspeorC.d.ts → suite-UrZdHRff.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -2
- package/dist/vendor/{base.QYERqzkH.js → base.N3JkKp7j.js} +1 -1
- package/dist/vendor/{base.Rmxiv35Y.js → base.Z38YsPLm.js} +2 -2
- package/dist/vendor/{benchmark.IlKmJkUU.js → benchmark.eeqk2rd8.js} +1 -1
- package/dist/vendor/{node.Zme77R4t.js → cac.wWT9ELdg.js} +9225 -5219
- package/dist/vendor/{constants.i1PoEnhr.js → constants.K-Wf1PUy.js} +3 -1
- package/dist/vendor/{execute.TxmaEFIQ.js → execute.27Kk4lQF.js} +23 -12
- package/dist/vendor/{index.cAUulNDf.js → index.8bPxjt7g.js} +6 -1
- package/dist/vendor/{index.RDKo8czB.js → index.9hqYxJUw.js} +7 -3
- package/dist/vendor/{environments.sU0TD7wX.js → index.GVFv9dZ0.js} +3 -0
- package/dist/vendor/{index.LgG0iblq.js → index.JZMafwT-.js} +4 -3
- package/dist/vendor/index.c1V_jzyZ.js +4927 -0
- package/dist/vendor/{index.rJjbcrrp.js → index.ir9i0ywP.js} +1 -1
- package/dist/vendor/{rpc.w4v8oCkK.js → rpc.joBhAkyK.js} +10 -1
- package/dist/vendor/setup-common.snyQUvE3.js +45 -0
- package/dist/vendor/{vi.PPwhENHF.js → vi.C5mroSoP.js} +2 -1
- package/dist/vendor/{vm.jVxKtN5R.js → vm.o1IruPAo.js} +25 -8
- package/dist/worker.js +5 -10
- package/dist/workers/forks.js +3 -3
- package/dist/workers/runVmTests.js +13 -9
- package/dist/workers/threads.js +3 -3
- package/dist/workers/vmForks.js +4 -4
- package/dist/workers/vmThreads.js +4 -4
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +8 -8
- package/globals.d.ts +2 -0
- package/jsdom.d.ts +6 -0
- package/package.json +24 -21
- package/dist/chunks/api-setup.srzH0bDf.js +0 -4808
- package/dist/vendor/reporters.cA9x-5v-.js +0 -2664
- package/dist/vendor/setup-common.C2iBd0K0.js +0 -29
|
@@ -56,7 +56,9 @@ const globalApis = [
|
|
|
56
56
|
"beforeAll",
|
|
57
57
|
"afterAll",
|
|
58
58
|
"beforeEach",
|
|
59
|
-
"afterEach"
|
|
59
|
+
"afterEach",
|
|
60
|
+
"onTestFinished",
|
|
61
|
+
"onTestFailed"
|
|
60
62
|
];
|
|
61
63
|
|
|
62
64
|
export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
|
|
@@ -7,7 +7,7 @@ import { processError } from '@vitest/utils/error';
|
|
|
7
7
|
import { distDir } from '../path.js';
|
|
8
8
|
import { existsSync, readdirSync } from 'node:fs';
|
|
9
9
|
import { highlight, getType } from '@vitest/utils';
|
|
10
|
-
import {
|
|
10
|
+
import { g as getAllMockableProperties } from './base.N3JkKp7j.js';
|
|
11
11
|
|
|
12
12
|
const spyModulePath = resolve(distDir, "spy.js");
|
|
13
13
|
class RefTracker {
|
|
@@ -369,12 +369,10 @@ async function createVitestExecutor(options) {
|
|
|
369
369
|
}
|
|
370
370
|
const externalizeMap = /* @__PURE__ */ new Map();
|
|
371
371
|
const bareVitestRegexp = /^@?vitest(\/|$)/;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
|
377
|
-
};
|
|
372
|
+
const dispose = [];
|
|
373
|
+
function listenForErrors(state) {
|
|
374
|
+
dispose.forEach((fn) => fn());
|
|
375
|
+
dispose.length = 0;
|
|
378
376
|
function catchError(err, type) {
|
|
379
377
|
var _a;
|
|
380
378
|
const worker = state();
|
|
@@ -385,11 +383,24 @@ async function startVitestExecutor(options) {
|
|
|
385
383
|
error.VITEST_TEST_PATH = relative(state().config.root, worker.filepath);
|
|
386
384
|
error.VITEST_AFTER_ENV_TEARDOWN = worker.environmentTeardownRun;
|
|
387
385
|
}
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
process.on("
|
|
386
|
+
state().rpc.onUnhandledError(error, type);
|
|
387
|
+
}
|
|
388
|
+
const uncaughtException = (e) => catchError(e, "Uncaught Exception");
|
|
389
|
+
const unhandledRejection = (e) => catchError(e, "Unhandled Rejection");
|
|
390
|
+
process.on("uncaughtException", uncaughtException);
|
|
391
|
+
process.on("unhandledRejection", unhandledRejection);
|
|
392
|
+
dispose.push(() => {
|
|
393
|
+
process.off("uncaughtException", uncaughtException);
|
|
394
|
+
process.off("unhandledRejection", unhandledRejection);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
async function startVitestExecutor(options) {
|
|
398
|
+
const state = () => globalThis.__vitest_worker__ || options.state;
|
|
399
|
+
const rpc = () => state().rpc;
|
|
400
|
+
process.exit = (code = process.exitCode || 0) => {
|
|
401
|
+
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
|
402
|
+
};
|
|
403
|
+
listenForErrors(state);
|
|
393
404
|
const getTransformMode = () => {
|
|
394
405
|
return state().environment.transformMode ?? "ssr";
|
|
395
406
|
};
|
|
@@ -35,7 +35,12 @@ function createBirpc(functions, options) {
|
|
|
35
35
|
let timeoutId;
|
|
36
36
|
if (timeout >= 0) {
|
|
37
37
|
timeoutId = setTimeout(() => {
|
|
38
|
-
|
|
38
|
+
try {
|
|
39
|
+
options.onTimeoutError?.(method, args);
|
|
40
|
+
throw new Error(`[birpc] timeout on calling "${method}"`);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
39
44
|
rpcPromiseMap.delete(id);
|
|
40
45
|
}, timeout).unref?.();
|
|
41
46
|
}
|
|
@@ -3,9 +3,9 @@ import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
|
3
3
|
import { resolve } from 'pathe';
|
|
4
4
|
import { distDir } from '../path.js';
|
|
5
5
|
import { g as getWorkerState } from './global.CkGT_TMy.js';
|
|
6
|
-
import { r as rpc } from './rpc.
|
|
6
|
+
import { r as rpc } from './rpc.joBhAkyK.js';
|
|
7
7
|
import { t as takeCoverageInsideWorker } from './coverage.E7sG1b3r.js';
|
|
8
|
-
import { l as loadDiffConfig } from './setup-common.
|
|
8
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.snyQUvE3.js';
|
|
9
9
|
|
|
10
10
|
function setupChaiConfig(config) {
|
|
11
11
|
Object.assign(chai.config, config);
|
|
@@ -47,7 +47,11 @@ async function resolveTestRunner(config, executor) {
|
|
|
47
47
|
testRunner.config = config;
|
|
48
48
|
if (!testRunner.importFile)
|
|
49
49
|
throw new Error('Runner must implement "importFile" method.');
|
|
50
|
-
|
|
50
|
+
const [diffOptions] = await Promise.all([
|
|
51
|
+
loadDiffConfig(config, executor),
|
|
52
|
+
loadSnapshotSerializers(config, executor)
|
|
53
|
+
]);
|
|
54
|
+
testRunner.config.diffOptions = diffOptions;
|
|
51
55
|
const originalOnTaskUpdate = testRunner.onTaskUpdate;
|
|
52
56
|
testRunner.onTaskUpdate = async (task) => {
|
|
53
57
|
const p = rpc().onTaskUpdate(task);
|
|
@@ -472,6 +472,7 @@ var jsdom = {
|
|
|
472
472
|
);
|
|
473
473
|
const clearWindowErrors = catchWindowErrors(dom.window);
|
|
474
474
|
dom.window.Buffer = Buffer;
|
|
475
|
+
dom.window.jsdom = dom;
|
|
475
476
|
const globalNames = [
|
|
476
477
|
"structuredClone",
|
|
477
478
|
"fetch",
|
|
@@ -536,10 +537,12 @@ var jsdom = {
|
|
|
536
537
|
);
|
|
537
538
|
const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
|
|
538
539
|
const clearWindowErrors = catchWindowErrors(global);
|
|
540
|
+
global.jsdom = dom;
|
|
539
541
|
return {
|
|
540
542
|
teardown(global2) {
|
|
541
543
|
clearWindowErrors();
|
|
542
544
|
dom.window.close();
|
|
545
|
+
delete global2.jsdom;
|
|
543
546
|
keys.forEach((key) => delete global2[key]);
|
|
544
547
|
originals.forEach((v, k) => global2[k] = v);
|
|
545
548
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
|
-
import { b as bench } from './benchmark.
|
|
1
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
|
+
import { b as bench } from './benchmark.eeqk2rd8.js';
|
|
3
3
|
import { i as isFirstRun, a as runOnce } from './run-once.Olz_Zkd8.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.C5mroSoP.js';
|
|
5
5
|
import { g as getWorkerState } from './global.CkGT_TMy.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
import { assert, should } from 'chai';
|
|
@@ -117,6 +117,7 @@ var VitestIndex = /*#__PURE__*/Object.freeze({
|
|
|
117
117
|
isWatchMode: isWatchMode,
|
|
118
118
|
it: it,
|
|
119
119
|
onTestFailed: onTestFailed,
|
|
120
|
+
onTestFinished: onTestFinished,
|
|
120
121
|
runOnce: runOnce,
|
|
121
122
|
should: should,
|
|
122
123
|
suite: suite,
|