vitest 0.29.7 → 0.30.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/LICENSE.md +3 -266
- package/dist/browser.d.ts +16 -4
- package/dist/browser.js +5 -4
- package/dist/child.js +12 -17
- package/dist/{chunk-api-setup.ac7748ac.js → chunk-api-setup.6662587e.js} +65 -51
- package/dist/{chunk-install-pkg.863031f2.js → chunk-install-pkg.6450b372.js} +33 -32
- package/dist/chunk-integrations-globals.d419838f.js +26 -0
- package/dist/{chunk-node-git.ed5bded8.js → chunk-node-git.4c43bd73.js} +4 -2
- package/dist/cli-wrapper.js +6 -5
- package/dist/cli.js +27 -26
- package/dist/config.cjs +15 -7
- package/dist/config.d.ts +15 -8
- package/dist/config.js +10 -6
- package/dist/coverage.d.ts +5 -2
- package/dist/coverage.js +6 -0
- package/dist/entry.js +35 -34
- package/dist/environments.d.ts +5 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +17 -21
- package/dist/index.js +9 -10
- package/dist/loader.js +396 -12
- package/dist/node.d.ts +9 -7
- package/dist/node.js +28 -30
- package/dist/runners.d.ts +5 -2
- package/dist/runners.js +34 -30
- package/dist/{types-fafda418.d.ts → types-f03c83c4.d.ts} +243 -317
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/dist/{chunk-node-pkg.f9696901.js → vendor-cli-api.c04eaa34.js} +3858 -5514
- package/dist/vendor-constants.538d9b49.js +54 -0
- package/dist/{chunk-integrations-coverage.e0a6acd2.js → vendor-coverage.a585b712.js} +5 -5
- package/dist/{chunk-runtime-mocker.344fec90.js → vendor-execute.8eaab47b.js} +9 -12
- package/dist/vendor-global.6795f91f.js +8 -0
- package/dist/vendor-index.4f82d248.js +161 -0
- package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
- package/dist/{chunk-integrations-utils.d7c85bd9.js → vendor-index.81b9e499.js} +22 -21
- package/dist/{vendor-index.2cbcdd1e.js → vendor-index.c1e09929.js} +458 -373
- package/dist/vendor-index.fad2598b.js +44 -0
- package/dist/{vendor-index.534e612c.js → vendor-index.fc98d30f.js} +2 -2
- package/dist/{chunk-runtime-inspector.b1427a10.js → vendor-inspector.47fc8cbb.js} +5 -2
- package/dist/{chunk-runtime-rpc.1b5714dc.js → vendor-rpc.4d3d7a54.js} +5 -5
- package/dist/{chunk-integrations-run-once.a2b4758b.js → vendor-run-once.69ce7172.js} +3 -2
- package/dist/{chunk-runtime-setup.a49dc2f9.js → vendor-setup.common.cef38f4e.js} +2 -2
- package/dist/vendor-tasks.042d6084.js +14 -0
- package/dist/{chunk-utils-import.39ffe9c5.js → vendor-vi.a3ff54b1.js} +262 -3147
- package/dist/worker.js +13 -19
- package/package.json +40 -34
- package/utils.d.ts +1 -0
- package/dist/chunk-constants.bc18a549.js +0 -36
- package/dist/chunk-integrations-globals.a473e88a.js +0 -27
- package/dist/chunk-snapshot-env.a347d647.js +0 -11
- package/dist/chunk-utils-base.81f83dbd.js +0 -88
- package/dist/chunk-utils-env.04ffbef7.js +0 -70
- package/dist/chunk-utils-tasks.b41c8284.js +0 -107
- package/dist/env-afee91f0.d.ts +0 -10
- package/dist/vendor-index.783e7f3e.js +0 -71
- package/dist/vendor-index.bdee400f.js +0 -396
- package/dist/vendor-magic-string.es.b3bc5745.js +0 -1591
- /package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.76cdd49e.js} +0 -0
- /package/dist/{chunk-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
package/dist/runners.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.a3ff54b1.js';
|
|
3
|
+
import './vendor-index.fad2598b.js';
|
|
4
|
+
import { r as rpc } from './vendor-rpc.4d3d7a54.js';
|
|
5
|
+
import { g as getFullName } from './vendor-tasks.042d6084.js';
|
|
6
|
+
import { g as getWorkerState } from './vendor-global.6795f91f.js';
|
|
7
|
+
import { getNames } from '@vitest/runner/utils';
|
|
5
8
|
import { updateTask } from '@vitest/runner';
|
|
6
9
|
import { createDefer, getSafeTimers } from '@vitest/utils';
|
|
7
|
-
import '@vitest/runner/utils';
|
|
8
10
|
import 'chai';
|
|
9
|
-
import './vendor-_commonjsHelpers.
|
|
10
|
-
import '
|
|
11
|
-
import 'pathe';
|
|
12
|
-
import './chunk-snapshot-env.a347d647.js';
|
|
13
|
-
import './chunk-utils-base.81f83dbd.js';
|
|
11
|
+
import './vendor-_commonjsHelpers.76cdd49e.js';
|
|
12
|
+
import '@vitest/snapshot';
|
|
14
13
|
import 'util';
|
|
15
14
|
import '@vitest/spy';
|
|
15
|
+
import 'pathe';
|
|
16
16
|
import 'std-env';
|
|
17
17
|
|
|
18
18
|
class VitestTestRunner {
|
|
@@ -30,7 +30,9 @@ class VitestTestRunner {
|
|
|
30
30
|
this.snapshotClient.clear();
|
|
31
31
|
}
|
|
32
32
|
async onAfterRun() {
|
|
33
|
-
await this.snapshotClient.
|
|
33
|
+
const result = await this.snapshotClient.resetCurrent();
|
|
34
|
+
if (result)
|
|
35
|
+
await rpc().snapshotSaved(result);
|
|
34
36
|
}
|
|
35
37
|
onAfterRunSuite(suite) {
|
|
36
38
|
if (this.config.logHeapUsage && typeof process !== "undefined")
|
|
@@ -43,12 +45,13 @@ class VitestTestRunner {
|
|
|
43
45
|
this.workerState.current = void 0;
|
|
44
46
|
}
|
|
45
47
|
async onBeforeRunTest(test) {
|
|
48
|
+
const name = getNames(test).slice(1).join(" > ");
|
|
46
49
|
if (test.mode !== "run") {
|
|
47
|
-
this.snapshotClient.skipTestSnapshots(
|
|
50
|
+
this.snapshotClient.skipTestSnapshots(name);
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
50
53
|
clearModuleMocks(this.config);
|
|
51
|
-
await this.snapshotClient.setTest(test);
|
|
54
|
+
await this.snapshotClient.setTest(test.file.filepath, name, this.workerState.config.snapshotOptions);
|
|
52
55
|
this.workerState.current = test;
|
|
53
56
|
}
|
|
54
57
|
onBeforeTryTest(test) {
|
|
@@ -71,6 +74,7 @@ class VitestTestRunner {
|
|
|
71
74
|
expectedAssertionsNumberErrorGen,
|
|
72
75
|
isExpectingAssertions,
|
|
73
76
|
isExpectingAssertionsError
|
|
77
|
+
// @ts-expect-error local is untyped
|
|
74
78
|
} = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
75
79
|
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
76
80
|
throw expectedAssertionsNumberErrorGen();
|
|
@@ -110,7 +114,7 @@ function clearModuleMocks(config) {
|
|
|
110
114
|
|
|
111
115
|
async function importTinybench() {
|
|
112
116
|
if (!globalThis.EventTarget)
|
|
113
|
-
await import('./vendor-index.
|
|
117
|
+
await import('./vendor-index.fc98d30f.js').then(function (n) { return n.i; });
|
|
114
118
|
return await import('tinybench');
|
|
115
119
|
}
|
|
116
120
|
function createBenchmarkResult(name) {
|
|
@@ -178,27 +182,27 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
178
182
|
defer.reject(_benchmark ? task.result.error : e);
|
|
179
183
|
});
|
|
180
184
|
});
|
|
181
|
-
|
|
185
|
+
const tasks = [];
|
|
186
|
+
for (const benchmark of benchmarkGroup) {
|
|
182
187
|
await benchmark.meta.task.warmup();
|
|
183
188
|
const { setTimeout } = getSafeTimers();
|
|
184
|
-
|
|
189
|
+
tasks.push(await new Promise((resolve) => setTimeout(async () => {
|
|
185
190
|
resolve(await benchmark.meta.task.run());
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
updateTask$1(suite);
|
|
200
|
-
defer.resolve(null);
|
|
191
|
+
})));
|
|
192
|
+
}
|
|
193
|
+
suite.result.duration = performance.now() - start;
|
|
194
|
+
suite.result.state = "pass";
|
|
195
|
+
tasks.sort((a, b) => a.result.mean - b.result.mean).forEach((cycle, idx) => {
|
|
196
|
+
const benchmark = benchmarkMap[cycle.name || ""];
|
|
197
|
+
benchmark.result.state = "pass";
|
|
198
|
+
if (benchmark) {
|
|
199
|
+
const result = benchmark.result.benchmark;
|
|
200
|
+
result.rank = Number(idx) + 1;
|
|
201
|
+
updateTask$1(benchmark);
|
|
202
|
+
}
|
|
201
203
|
});
|
|
204
|
+
updateTask$1(suite);
|
|
205
|
+
defer.resolve(null);
|
|
202
206
|
await defer;
|
|
203
207
|
}
|
|
204
208
|
function updateTask$1(task) {
|