vitest 0.34.6 → 1.0.0-beta.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/README.md +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/child.js +21 -19
- package/dist/{chunk-api-setup.d65b007d.js → chunk-api-setup.0aeabd21.js} +1 -1
- package/dist/{chunk-install-pkg.6c4f388a.js → chunk-install-pkg.a430b45e.js} +5 -4
- package/dist/{chunk-integrations-globals.5afac659.js → chunk-integrations-globals.c3c5e678.js} +4 -3
- package/dist/cli.js +11 -6
- package/dist/config.cjs +1 -2
- package/dist/config.d.ts +2 -3
- package/dist/config.js +1 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/entry-vm.js +5 -4
- package/dist/entry.js +8 -4
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/index.d.ts +9 -10
- package/dist/index.js +4 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +7 -6
- package/dist/{reporters-5f784f42.d.ts → reporters-7bd09217.d.ts} +165 -103
- package/dist/reporters.d.ts +1 -1
- package/dist/runners.d.ts +10 -10
- package/dist/runners.js +13 -12
- package/dist/suite-543d56bd.d.ts +10 -0
- package/dist/suite.d.ts +15 -1
- package/dist/suite.js +7 -1
- package/dist/vendor-benchmark.44931cfa.js +41 -0
- package/dist/{vendor-environments.7aba93d9.js → vendor-environments.e73c5410.js} +14 -2
- package/dist/{vendor-index.b271ebe4.js → vendor-index.1ca68bd5.js} +7 -5
- package/dist/{vendor-index.3e351f42.js → vendor-index.d36f5516.js} +5 -5
- package/dist/{vendor-index.7646b3af.js → vendor-index.f7fcd5e8.js} +2 -1
- package/dist/vendor-inspector.209edf5a.js +26 -0
- package/dist/{vendor-node.a7c48fe1.js → vendor-node.bde9fb47.js} +413 -298
- package/dist/{vendor-vi.6873a1c1.js → vendor-vi.7f2b988f.js} +28 -53
- package/dist/vm.js +2 -2
- package/dist/worker.js +7 -4
- package/package.json +14 -13
- package/dist/vendor-inspector.47fc8cbb.js +0 -23
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { getCurrentSuite, getCurrentTest } from '@vitest/runner';
|
|
2
|
-
import { createChainable, getNames } from '@vitest/runner/utils';
|
|
3
|
-
import { getSafeTimers, noop, assertTypes, createSimpleStackTrace } from '@vitest/utils';
|
|
4
|
-
import { i as isRunningInBenchmark } from './vendor-index.29282562.js';
|
|
5
1
|
import * as chai$1 from 'chai';
|
|
6
2
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './vendor-_commonjsHelpers.7d1333e8.js';
|
|
7
3
|
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT as GLOBAL_EXPECT$1, getState, setState } from '@vitest/expect';
|
|
8
|
-
import {
|
|
4
|
+
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
|
|
5
|
+
import { getNames } from '@vitest/runner/utils';
|
|
9
6
|
import '@vitest/utils/error';
|
|
7
|
+
import { getCurrentTest } from '@vitest/runner';
|
|
10
8
|
import { g as getFullName } from './vendor-tasks.f9d75aed.js';
|
|
11
9
|
import { g as getWorkerState, a as getCurrentEnvironment } from './vendor-global.97e4527c.js';
|
|
10
|
+
import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
|
|
12
11
|
import { parseSingleStack } from '@vitest/utils/source-map';
|
|
13
12
|
import require$$2 from 'util';
|
|
14
13
|
import { R as RealDate, r as resetDate, m as mockDate } from './vendor-date.6e993429.js';
|
|
@@ -53,39 +52,6 @@ async function waitForImportsToResolve() {
|
|
|
53
52
|
await waitForImportsToResolve();
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
const benchFns = /* @__PURE__ */ new WeakMap();
|
|
57
|
-
const benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
58
|
-
function getBenchOptions(key) {
|
|
59
|
-
return benchOptsMap.get(key);
|
|
60
|
-
}
|
|
61
|
-
function getBenchFn(key) {
|
|
62
|
-
return benchFns.get(key);
|
|
63
|
-
}
|
|
64
|
-
const bench = createBenchmark(
|
|
65
|
-
function(name, fn = noop, options = {}) {
|
|
66
|
-
if (!isRunningInBenchmark())
|
|
67
|
-
throw new Error("`bench()` is only available in benchmark mode.");
|
|
68
|
-
const task = getCurrentSuite().custom.call(this, formatName(name));
|
|
69
|
-
task.meta = {
|
|
70
|
-
benchmark: true
|
|
71
|
-
};
|
|
72
|
-
benchFns.set(task, fn);
|
|
73
|
-
benchOptsMap.set(task, options);
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
function createBenchmark(fn) {
|
|
77
|
-
const benchmark = createChainable(
|
|
78
|
-
["skip", "only", "todo"],
|
|
79
|
-
fn
|
|
80
|
-
);
|
|
81
|
-
benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
|
|
82
|
-
benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
|
|
83
|
-
return benchmark;
|
|
84
|
-
}
|
|
85
|
-
function formatName(name) {
|
|
86
|
-
return typeof name === "string" ? name : name instanceof Function ? name.name || "<anonymous>" : String(name);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
55
|
function commonjsRequire(path) {
|
|
90
56
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
91
57
|
}
|
|
@@ -209,16 +175,15 @@ function recordAsyncExpect(test, promise) {
|
|
|
209
175
|
return promise;
|
|
210
176
|
}
|
|
211
177
|
|
|
212
|
-
class VitestSnapshotClient extends SnapshotClient {
|
|
213
|
-
equalityCheck(received, expected) {
|
|
214
|
-
return equals(received, expected, [iterableEquality, subsetEquality]);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
178
|
let _client;
|
|
219
179
|
function getSnapshotClient() {
|
|
220
|
-
if (!_client)
|
|
221
|
-
_client = new
|
|
180
|
+
if (!_client) {
|
|
181
|
+
_client = new SnapshotClient({
|
|
182
|
+
isEqual: (received, expected) => {
|
|
183
|
+
return equals(received, expected, [iterableEquality, subsetEquality]);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
222
187
|
return _client;
|
|
223
188
|
}
|
|
224
189
|
function getErrorMessage(err) {
|
|
@@ -3127,13 +3092,16 @@ class FakeTimers {
|
|
|
3127
3092
|
}
|
|
3128
3093
|
}
|
|
3129
3094
|
useFakeTimers() {
|
|
3095
|
+
var _a, _b;
|
|
3130
3096
|
if (this._fakingDate) {
|
|
3131
3097
|
throw new Error(
|
|
3132
3098
|
'"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.'
|
|
3133
3099
|
);
|
|
3134
3100
|
}
|
|
3135
3101
|
if (!this._fakingTime) {
|
|
3136
|
-
const toFake = Object.keys(this._fakeTimers.timers);
|
|
3102
|
+
const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick");
|
|
3103
|
+
if (((_b = (_a = this._userConfig) == null ? void 0 : _a.toFake) == null ? void 0 : _b.includes("nextTick")) && globalThis.__vitest_worker__.isChildProcess)
|
|
3104
|
+
throw new Error("process.nextTick cannot be mocked inside child_process");
|
|
3137
3105
|
this._clock = this._fakeTimers.install({
|
|
3138
3106
|
now: Date.now(),
|
|
3139
3107
|
toFake,
|
|
@@ -3328,12 +3296,19 @@ function createVitest() {
|
|
|
3328
3296
|
};
|
|
3329
3297
|
const utils = {
|
|
3330
3298
|
useFakeTimers(config) {
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3299
|
+
var _a, _b, _c, _d;
|
|
3300
|
+
const workerState2 = getWorkerState();
|
|
3301
|
+
if (workerState2.isChildProcess) {
|
|
3302
|
+
if (((_a = config == null ? void 0 : config.toFake) == null ? void 0 : _a.includes("nextTick")) || ((_d = (_c = (_b = workerState2.config) == null ? void 0 : _b.fakeTimers) == null ? void 0 : _c.toFake) == null ? void 0 : _d.includes("nextTick"))) {
|
|
3303
|
+
throw new Error(
|
|
3304
|
+
'vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.'
|
|
3305
|
+
);
|
|
3306
|
+
}
|
|
3336
3307
|
}
|
|
3308
|
+
if (config)
|
|
3309
|
+
_timers.configure({ ...workerState2.config.fakeTimers, ...config });
|
|
3310
|
+
else
|
|
3311
|
+
_timers.configure(workerState2.config.fakeTimers);
|
|
3337
3312
|
_timers.useFakeTimers();
|
|
3338
3313
|
return utils;
|
|
3339
3314
|
},
|
|
@@ -3513,4 +3488,4 @@ function createVitest() {
|
|
|
3513
3488
|
const vitest = createVitest();
|
|
3514
3489
|
const vi = vitest;
|
|
3515
3490
|
|
|
3516
|
-
export {
|
|
3491
|
+
export { globalExpect as a, vitest as b, createExpect as c, getSnapshotClient as g, resetModules as r, vi as v };
|
package/dist/vm.js
CHANGED
|
@@ -3,11 +3,11 @@ import { performance } from 'node:perf_hooks';
|
|
|
3
3
|
import { isContext } from 'node:vm';
|
|
4
4
|
import { ModuleCacheMap } from 'vite-node/client';
|
|
5
5
|
import { workerId } from 'tinypool';
|
|
6
|
-
import { c as createBirpc } from './vendor-index.
|
|
6
|
+
import { c as createBirpc } from './vendor-index.1ca68bd5.js';
|
|
7
7
|
import { resolve } from 'pathe';
|
|
8
8
|
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
9
|
import { d as distDir } from './vendor-paths.84fc7a99.js';
|
|
10
|
-
import { l as loadEnvironment } from './vendor-environments.
|
|
10
|
+
import { l as loadEnvironment } from './vendor-environments.e73c5410.js';
|
|
11
11
|
import { b as startVitestExecutor } from './vendor-execute.07d1a420.js';
|
|
12
12
|
import { createCustomConsole } from './chunk-runtime-console.ea222ffb.js';
|
|
13
13
|
import { c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
|
package/dist/worker.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
|
-
import { c as createBirpc } from './vendor-index.
|
|
2
|
+
import { c as createBirpc } from './vendor-index.1ca68bd5.js';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
4
|
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
5
|
-
import { l as loadEnvironment } from './vendor-environments.
|
|
5
|
+
import { l as loadEnvironment } from './vendor-environments.e73c5410.js';
|
|
6
6
|
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.07d1a420.js';
|
|
7
|
-
import { s as setupInspect } from './vendor-inspector.
|
|
7
|
+
import { s as setupInspect } from './vendor-inspector.209edf5a.js';
|
|
8
8
|
import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
|
|
9
9
|
import 'pathe';
|
|
10
10
|
import './vendor-index.0b5b3600.js';
|
|
@@ -29,7 +29,10 @@ import './vendor-base.9c08bbd0.js';
|
|
|
29
29
|
import 'vite-node/constants';
|
|
30
30
|
|
|
31
31
|
async function init(ctx) {
|
|
32
|
-
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const isInitialized = typeof __vitest_worker__ !== "undefined";
|
|
34
|
+
const isIsolatedThreads = ctx.config.pool === "threads" && (((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) ?? true);
|
|
35
|
+
if (isInitialized && isIsolatedThreads)
|
|
33
36
|
throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
|
|
34
37
|
const { config, port, workerId: workerId$1 } = ctx;
|
|
35
38
|
process.env.VITEST_WORKER_ID = String(workerId$1);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.0.0-beta.1",
|
|
5
|
+
"description": "Next generation testing framework powered by Vite",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"@edge-runtime/vm": "*",
|
|
105
|
+
"@types/node": ">= 14",
|
|
105
106
|
"@vitest/browser": "*",
|
|
106
107
|
"@vitest/ui": "*",
|
|
107
108
|
"happy-dom": "*",
|
|
@@ -111,6 +112,9 @@
|
|
|
111
112
|
"webdriverio": "*"
|
|
112
113
|
},
|
|
113
114
|
"peerDependenciesMeta": {
|
|
115
|
+
"@types/node": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
114
118
|
"@vitest/ui": {
|
|
115
119
|
"optional": true
|
|
116
120
|
},
|
|
@@ -137,9 +141,6 @@
|
|
|
137
141
|
}
|
|
138
142
|
},
|
|
139
143
|
"dependencies": {
|
|
140
|
-
"@types/chai": "^4.3.5",
|
|
141
|
-
"@types/chai-subset": "^1.3.3",
|
|
142
|
-
"@types/node": "*",
|
|
143
144
|
"acorn": "^8.9.0",
|
|
144
145
|
"acorn-walk": "^8.2.0",
|
|
145
146
|
"cac": "^6.7.14",
|
|
@@ -152,15 +153,15 @@
|
|
|
152
153
|
"std-env": "^3.3.3",
|
|
153
154
|
"strip-literal": "^1.0.1",
|
|
154
155
|
"tinybench": "^2.5.0",
|
|
155
|
-
"tinypool": "^0.
|
|
156
|
+
"tinypool": "^0.8.1",
|
|
156
157
|
"vite": "^3.1.0 || ^4.0.0 || ^5.0.0-0",
|
|
157
158
|
"why-is-node-running": "^2.2.2",
|
|
158
|
-
"@vitest/runner": "0.
|
|
159
|
-
"@vitest/
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"@vitest/
|
|
163
|
-
"@vitest/
|
|
159
|
+
"@vitest/runner": "1.0.0-beta.1",
|
|
160
|
+
"@vitest/snapshot": "1.0.0-beta.1",
|
|
161
|
+
"@vitest/utils": "1.0.0-beta.1",
|
|
162
|
+
"vite-node": "1.0.0-beta.1",
|
|
163
|
+
"@vitest/spy": "1.0.0-beta.1",
|
|
164
|
+
"@vitest/expect": "1.0.0-beta.1"
|
|
164
165
|
},
|
|
165
166
|
"devDependencies": {
|
|
166
167
|
"@ampproject/remapping": "^2.2.1",
|
|
@@ -175,7 +176,7 @@
|
|
|
175
176
|
"@types/micromatch": "^4.0.2",
|
|
176
177
|
"@types/prompts": "^2.4.4",
|
|
177
178
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
178
|
-
"birpc": "0.2.
|
|
179
|
+
"birpc": "0.2.14",
|
|
179
180
|
"chai-subset": "^1.6.0",
|
|
180
181
|
"cli-truncate": "^3.1.0",
|
|
181
182
|
"event-target-polyfill": "^0.0.3",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
|
|
3
|
-
const __require = createRequire(import.meta.url);
|
|
4
|
-
let inspector;
|
|
5
|
-
function setupInspect(config) {
|
|
6
|
-
const isEnabled = config.inspect || config.inspectBrk;
|
|
7
|
-
if (isEnabled) {
|
|
8
|
-
inspector = __require("node:inspector");
|
|
9
|
-
const isOpen = inspector.url() !== void 0;
|
|
10
|
-
if (!isOpen) {
|
|
11
|
-
inspector.open();
|
|
12
|
-
if (config.inspectBrk)
|
|
13
|
-
inspector.waitForDebugger();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const keepOpen = config.watch && !config.isolate && config.singleThread;
|
|
17
|
-
return function cleanup() {
|
|
18
|
-
if (isEnabled && !keepOpen && inspector)
|
|
19
|
-
inspector.close();
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { setupInspect as s };
|