vitest 1.0.0-beta.1 → 1.0.0-beta.3
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 +0 -29
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/child.js +9 -4
- package/dist/{chunk-api-setup.0aeabd21.js → chunk-api-setup.37a43981.js} +3 -2
- package/dist/{chunk-install-pkg.a430b45e.js → chunk-install-pkg.6349b322.js} +22 -21
- package/dist/{chunk-integrations-globals.c3c5e678.js → chunk-integrations-globals.9df12d91.js} +2 -3
- package/dist/{chunk-node-git.36288174.js → chunk-node-git.6c12e560.js} +1 -1
- package/dist/{chunk-runtime-console.ea222ffb.js → chunk-runtime-console.f3263f87.js} +19 -4
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +14 -18
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.js +2 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +2 -2
- package/dist/entry-vm.js +9 -4
- package/dist/entry.js +10 -5
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -13
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +3 -4
- package/dist/node.d.ts +5 -3
- package/dist/node.js +14 -13
- package/dist/{reporters-7bd09217.d.ts → reporters-1678fe04.d.ts} +84 -47
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +6 -1
- package/dist/runners.d.ts +3 -2
- package/dist/runners.js +33 -37
- package/dist/{suite-543d56bd.d.ts → suite-0579b50d.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/{vendor-environments.e73c5410.js → vendor-environments.dcc4a34e.js} +6 -37
- package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
- package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
- package/dist/{vendor-index.f7fcd5e8.js → vendor-index.68ecee35.js} +1 -1
- package/dist/{vendor-index.85fc950a.js → vendor-index.8efe7746.js} +375 -375
- package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
- package/dist/{vendor-node.bde9fb47.js → vendor-node.327f8f1f.js} +1996 -1984
- package/dist/{vendor-reporters.f6975b8d.js → vendor-reporters.b9600369.js} +42 -24
- package/dist/vendor-vi.d30b47ae.js +3510 -0
- package/dist/vm.js +10 -5
- package/dist/worker.js +9 -4
- package/package.json +12 -28
- package/dist/loader.js +0 -100
- package/dist/vendor-index.98139333.js +0 -129
- package/dist/vendor-vi.7f2b988f.js +0 -3491
package/dist/runners.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
2
|
-
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor-vi.
|
|
2
|
+
import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor-vi.d30b47ae.js';
|
|
3
3
|
import './vendor-index.29282562.js';
|
|
4
4
|
import { a as rpc } from './vendor-rpc.cbd8e972.js';
|
|
5
5
|
import { g as getFullName } from './vendor-tasks.f9d75aed.js';
|
|
@@ -14,7 +14,6 @@ import './vendor-_commonjsHelpers.7d1333e8.js';
|
|
|
14
14
|
import '@vitest/snapshot';
|
|
15
15
|
import '@vitest/utils/error';
|
|
16
16
|
import '@vitest/utils/source-map';
|
|
17
|
-
import 'util';
|
|
18
17
|
import './vendor-date.6e993429.js';
|
|
19
18
|
import '@vitest/spy';
|
|
20
19
|
import 'pathe';
|
|
@@ -128,11 +127,6 @@ function clearModuleMocks(config) {
|
|
|
128
127
|
vi.unstubAllGlobals();
|
|
129
128
|
}
|
|
130
129
|
|
|
131
|
-
async function importTinybench() {
|
|
132
|
-
if (!globalThis.EventTarget)
|
|
133
|
-
await import('./vendor-index.98139333.js').then(function (n) { return n.i; });
|
|
134
|
-
return await import('tinybench');
|
|
135
|
-
}
|
|
136
130
|
function createBenchmarkResult(name) {
|
|
137
131
|
return {
|
|
138
132
|
name,
|
|
@@ -144,7 +138,7 @@ function createBenchmarkResult(name) {
|
|
|
144
138
|
const benchmarkTasks = /* @__PURE__ */ new WeakMap();
|
|
145
139
|
async function runBenchmarkSuite(suite, runner) {
|
|
146
140
|
var _a;
|
|
147
|
-
const { Task, Bench } = await importTinybench();
|
|
141
|
+
const { Task, Bench } = await runner.importTinybench();
|
|
148
142
|
const start = performance.now();
|
|
149
143
|
const benchmarkGroup = [];
|
|
150
144
|
const benchmarkSuiteGroup = [];
|
|
@@ -160,14 +154,30 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
160
154
|
await Promise.all(benchmarkSuiteGroup.map((subSuite) => runBenchmarkSuite(subSuite, runner)));
|
|
161
155
|
if (benchmarkGroup.length) {
|
|
162
156
|
const defer = createDefer();
|
|
163
|
-
const benchmarkMap = {};
|
|
164
157
|
suite.result = {
|
|
165
158
|
state: "run",
|
|
166
159
|
startTime: start,
|
|
167
160
|
benchmark: createBenchmarkResult(suite.name)
|
|
168
161
|
};
|
|
169
162
|
updateTask$1(suite);
|
|
170
|
-
|
|
163
|
+
const addBenchTaskListener = (task, benchmark) => {
|
|
164
|
+
task.addEventListener("complete", (e) => {
|
|
165
|
+
const task2 = e.task;
|
|
166
|
+
const taskRes = task2.result;
|
|
167
|
+
const result = benchmark.result.benchmark;
|
|
168
|
+
Object.assign(result, taskRes);
|
|
169
|
+
updateTask$1(benchmark);
|
|
170
|
+
}, {
|
|
171
|
+
once: true
|
|
172
|
+
});
|
|
173
|
+
task.addEventListener("error", (e) => {
|
|
174
|
+
const task2 = e.task;
|
|
175
|
+
defer.reject(benchmark ? task2.result.error : e);
|
|
176
|
+
}, {
|
|
177
|
+
once: true
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
benchmarkGroup.forEach((benchmark) => {
|
|
171
181
|
const options = getBenchOptions(benchmark);
|
|
172
182
|
const benchmarkInstance = new Bench(options);
|
|
173
183
|
const benchmarkFn = getBenchFn(benchmark);
|
|
@@ -176,43 +186,26 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
176
186
|
startTime: start,
|
|
177
187
|
benchmark: createBenchmarkResult(benchmark.name)
|
|
178
188
|
};
|
|
179
|
-
const
|
|
180
|
-
benchmarkMap[id] = benchmark;
|
|
181
|
-
const task = new Task(benchmarkInstance, id, benchmarkFn);
|
|
189
|
+
const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
|
|
182
190
|
benchmarkTasks.set(benchmark, task);
|
|
191
|
+
addBenchTaskListener(task, benchmark);
|
|
183
192
|
updateTask$1(benchmark);
|
|
184
193
|
});
|
|
185
|
-
|
|
186
|
-
const task = benchmarkTasks.get(benchmark);
|
|
187
|
-
task.addEventListener("complete", (e) => {
|
|
188
|
-
const task2 = e.task;
|
|
189
|
-
const _benchmark = benchmarkMap[task2.name || ""];
|
|
190
|
-
if (_benchmark) {
|
|
191
|
-
const taskRes = task2.result;
|
|
192
|
-
const result = _benchmark.result.benchmark;
|
|
193
|
-
Object.assign(result, taskRes);
|
|
194
|
-
updateTask$1(_benchmark);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
task.addEventListener("error", (e) => {
|
|
198
|
-
const task2 = e.task;
|
|
199
|
-
const _benchmark = benchmarkMap[task2.name || ""];
|
|
200
|
-
defer.reject(_benchmark ? task2.result.error : e);
|
|
201
|
-
});
|
|
202
|
-
});
|
|
194
|
+
const { setTimeout } = getSafeTimers();
|
|
203
195
|
const tasks = [];
|
|
204
196
|
for (const benchmark of benchmarkGroup) {
|
|
205
197
|
const task = benchmarkTasks.get(benchmark);
|
|
206
198
|
await task.warmup();
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
tasks.push([
|
|
200
|
+
await new Promise((resolve) => setTimeout(async () => {
|
|
201
|
+
resolve(await task.run());
|
|
202
|
+
})),
|
|
203
|
+
benchmark
|
|
204
|
+
]);
|
|
211
205
|
}
|
|
212
206
|
suite.result.duration = performance.now() - start;
|
|
213
207
|
suite.result.state = "pass";
|
|
214
|
-
tasks.sort((
|
|
215
|
-
const benchmark = benchmarkMap[cycle.name || ""];
|
|
208
|
+
tasks.sort(([taskA], [taskB]) => taskA.result.mean - taskB.result.mean).forEach(([, benchmark], idx) => {
|
|
216
209
|
benchmark.result.state = "pass";
|
|
217
210
|
if (benchmark) {
|
|
218
211
|
const result = benchmark.result.benchmark;
|
|
@@ -233,6 +226,9 @@ class NodeBenchmarkRunner {
|
|
|
233
226
|
this.config = config;
|
|
234
227
|
}
|
|
235
228
|
__vitest_executor;
|
|
229
|
+
async importTinybench() {
|
|
230
|
+
return await import('tinybench');
|
|
231
|
+
}
|
|
236
232
|
importFile(filepath, source) {
|
|
237
233
|
if (source === "setup")
|
|
238
234
|
getWorkerState().moduleCache.delete(filepath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Custom } from '@vitest/runner';
|
|
2
2
|
import '@vitest/runner/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { ai as BenchFunction, aj as BenchmarkAPI } from './reporters-1678fe04.js';
|
|
4
4
|
import { Options } from 'tinybench';
|
|
5
5
|
|
|
6
6
|
declare function getBenchOptions(key: Custom): Options;
|
package/dist/suite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
|
|
2
2
|
export { createChainable } from '@vitest/runner/utils';
|
|
3
|
-
export { g as getBenchFn, a as getBenchOptions } from './suite-
|
|
4
|
-
import './reporters-
|
|
3
|
+
export { g as getBenchFn, a as getBenchOptions } from './suite-0579b50d.js';
|
|
4
|
+
import './reporters-1678fe04.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'vite-node';
|
|
7
7
|
import '@vitest/snapshot';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { resolve, normalize } from 'pathe';
|
|
2
|
-
import { r as resolvePath } from './vendor-index.0b5b3600.js';
|
|
3
|
-
import { ViteNodeRunner } from 'vite-node/client';
|
|
4
1
|
import { Console } from 'node:console';
|
|
5
2
|
import { importModule } from 'local-pkg';
|
|
6
3
|
|
|
@@ -479,7 +476,9 @@ var jsdom = {
|
|
|
479
476
|
"Response",
|
|
480
477
|
"BroadcastChannel",
|
|
481
478
|
"MessageChannel",
|
|
482
|
-
"MessagePort"
|
|
479
|
+
"MessagePort",
|
|
480
|
+
"TextEncoder",
|
|
481
|
+
"TextDecoder"
|
|
483
482
|
];
|
|
484
483
|
for (const name of globalNames) {
|
|
485
484
|
const value = globalThis[name];
|
|
@@ -646,44 +645,14 @@ const envPackageNames = {
|
|
|
646
645
|
"happy-dom": "happy-dom",
|
|
647
646
|
"edge-runtime": "@edge-runtime/vm"
|
|
648
647
|
};
|
|
649
|
-
function isBuiltinEnvironment(env) {
|
|
650
|
-
return env in environments;
|
|
651
|
-
}
|
|
652
648
|
function getEnvPackageName(env) {
|
|
653
649
|
if (env === "node")
|
|
654
650
|
return null;
|
|
655
651
|
if (env in envPackageNames)
|
|
656
652
|
return envPackageNames[env];
|
|
653
|
+
if (env[0] === "." || env[0] === "/")
|
|
654
|
+
return null;
|
|
657
655
|
return `vitest-environment-${env}`;
|
|
658
656
|
}
|
|
659
|
-
const _loaders = /* @__PURE__ */ new Map();
|
|
660
|
-
async function createEnvironmentLoader(options) {
|
|
661
|
-
if (!_loaders.has(options.root)) {
|
|
662
|
-
const loader = new ViteNodeRunner(options);
|
|
663
|
-
await loader.executeId("/@vite/env");
|
|
664
|
-
_loaders.set(options.root, loader);
|
|
665
|
-
}
|
|
666
|
-
return _loaders.get(options.root);
|
|
667
|
-
}
|
|
668
|
-
async function loadEnvironment(name, options) {
|
|
669
|
-
if (isBuiltinEnvironment(name))
|
|
670
|
-
return environments[name];
|
|
671
|
-
const loader = await createEnvironmentLoader(options);
|
|
672
|
-
const root = loader.root;
|
|
673
|
-
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : await resolvePath(`vitest-environment-${name}`, { url: [root] }) ?? resolve(root, name);
|
|
674
|
-
const pkg = await loader.executeId(normalize(packageId));
|
|
675
|
-
if (!pkg || !pkg.default || typeof pkg.default !== "object") {
|
|
676
|
-
throw new TypeError(
|
|
677
|
-
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
const environment = pkg.default;
|
|
681
|
-
if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
|
|
682
|
-
throw new TypeError(
|
|
683
|
-
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`
|
|
684
|
-
);
|
|
685
|
-
}
|
|
686
|
-
return environment;
|
|
687
|
-
}
|
|
688
657
|
|
|
689
|
-
export { environments as e, getEnvPackageName as g,
|
|
658
|
+
export { environments as e, getEnvPackageName as g, populateGlobal as p };
|
|
@@ -1009,6 +1009,7 @@ async function startVitestExecutor(options) {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
rpc().onUnhandledError(error, type);
|
|
1011
1011
|
}
|
|
1012
|
+
process.setMaxListeners(25);
|
|
1012
1013
|
process.on("uncaughtException", (e) => catchError(e, "Uncaught Exception"));
|
|
1013
1014
|
process.on("unhandledRejection", (e) => catchError(e, "Unhandled Rejection"));
|
|
1014
1015
|
const getTransformMode = () => {
|
|
@@ -68,8 +68,13 @@ async function resolveTestRunner(config, executor) {
|
|
|
68
68
|
};
|
|
69
69
|
const originalOnAfterRun = testRunner.onAfterRunFiles;
|
|
70
70
|
testRunner.onAfterRunFiles = async (files) => {
|
|
71
|
+
const state = getWorkerState();
|
|
71
72
|
const coverage = await takeCoverageInsideWorker(config.coverage, executor);
|
|
72
|
-
rpc().onAfterSuiteRun({
|
|
73
|
+
rpc().onAfterSuiteRun({
|
|
74
|
+
coverage,
|
|
75
|
+
transformMode: state.environment.transformMode,
|
|
76
|
+
projectName: state.ctx.projectName
|
|
77
|
+
});
|
|
73
78
|
await (originalOnAfterRun == null ? void 0 : originalOnAfterRun.call(testRunner, files));
|
|
74
79
|
};
|
|
75
80
|
const originalOnAfterRunTask = testRunner.onAfterRunTask;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
|
|
2
2
|
import { b as bench } from './vendor-benchmark.44931cfa.js';
|
|
3
3
|
import { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js';
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vendor-vi.
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vendor-vi.d30b47ae.js';
|
|
5
5
|
import * as chai from 'chai';
|
|
6
6
|
import { assert, should } from 'chai';
|
|
7
7
|
|