vitest 4.1.0-beta.5 → 4.1.0-beta.6
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/browser/context.d.ts +1 -1
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{base.BzdSbvqu.js → base.C98-6XAz.js} +8 -8
- package/dist/chunks/{cac.BvpGf9db.js → cac.Vtz91O0H.js} +6 -6
- package/dist/chunks/{cli-api.D__YrL6a.js → cli-api.Bqj5xGy5.js} +23 -12
- package/dist/chunks/{console.DpQfzR9G.js → console.3WNpx0tS.js} +1 -1
- package/dist/chunks/{globals.DgrX1FjK.js → globals.DA6L6i5h.js} +3 -3
- package/dist/chunks/{index.Bd3kKDSS.js → index.5lgR0kvt.js} +3 -3
- package/dist/chunks/{index.CPRfxlYj.js → index.CHsi7RlU.js} +1 -1
- package/dist/chunks/{index.mNs4_sfP.js → index.DpkD7Zj4.js} +262 -38
- package/dist/chunks/{index.CyBMJtT7.js → index.EY6TCHpo.js} +10 -8
- package/dist/chunks/{index.DqEi5Ycp.js → index.IcAjQV7n.js} +1 -1
- package/dist/chunks/{init-forks.Uz2iUy-b.js → init-forks.BwPkXyLk.js} +1 -1
- package/dist/chunks/{init-threads.u8FhyhU_.js → init-threads.BuSVu8Ns.js} +1 -1
- package/dist/chunks/{init.DzWSvu83.js → init.Borgldul.js} +3 -3
- package/dist/chunks/{nativeModuleMocker.Bt11nCqn.js → nativeModuleMocker.wQT5wU7r.js} +1 -1
- package/dist/chunks/{plugin.d.BA1SfGdt.d.ts → plugin.d.pmonRL8Y.d.ts} +1 -1
- package/dist/chunks/{reporters.d.pZWLB1PG.d.ts → reporters.d.CRDGoPlb.d.ts} +55 -12
- package/dist/chunks/{rpc.CYazvPD1.js → rpc.MzXet3jl.js} +1 -5
- package/dist/chunks/{setup-common.BRHvdzsc.js → setup-common.z3ZfZiWN.js} +1 -1
- package/dist/chunks/{startVitestModuleRunner.BRvQz4ko.js → startVitestModuleRunner.BdSYEN5x.js} +54 -12
- package/dist/chunks/{test.BwzWwv9M.js → test.PnxXDGpZ.js} +15 -3
- package/dist/chunks/{vm.D32oUcpO.js → vm.V092iA4c.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +3 -3
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/index.js +3 -3
- package/dist/node.d.ts +4 -4
- package/dist/node.js +6 -6
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +2 -2
- package/dist/runners.js +2 -2
- package/dist/runtime.js +2 -2
- package/dist/worker.js +9 -9
- package/dist/workers/forks.js +10 -10
- package/dist/workers/runVmTests.js +5 -5
- package/dist/workers/threads.js +10 -10
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# vitest
|
|
2
2
|
|
|
3
|
-
[](https://
|
|
3
|
+
[](https://npmx.dev/package/vitest)
|
|
4
4
|
|
|
5
5
|
Next generation testing framework powered by Vite.
|
|
6
6
|
|
package/browser/context.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export * from '@vitest/browser-playwright/context'
|
|
|
4
4
|
export * from '@vitest/browser-webdriverio/context'
|
|
5
5
|
// @ts-ignore -- @vitest/browser-preview might not be installed
|
|
6
6
|
export * from '@vitest/browser-preview/context'
|
|
7
|
-
export { BrowserCommands, FsOptions } from 'vitest/internal/browser'
|
|
7
|
+
export { BrowserCommands, CDPSession, FsOptions } from 'vitest/internal/browser'
|
package/dist/browser.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ interface BrowserCommands {
|
|
|
41
41
|
})) => Promise<void>;
|
|
42
42
|
removeFile: (path: string) => Promise<void>;
|
|
43
43
|
}
|
|
44
|
+
interface CDPSession {}
|
|
44
45
|
|
|
45
46
|
export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
|
|
46
|
-
export type { BrowserCommands, FsOptions };
|
|
47
|
+
export type { BrowserCommands, CDPSession, FsOptions };
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.
|
|
1
|
+
export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.z3ZfZiWN.js';
|
|
2
2
|
export { T as Traces } from './chunks/traces.CCmnQaNT.js';
|
|
3
3
|
export { collectTests, startTests } from '@vitest/runner';
|
|
4
4
|
import * as spyModule from '@vitest/spy';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { runInThisContext } from 'node:vm';
|
|
2
2
|
import * as spyModule from '@vitest/spy';
|
|
3
|
-
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.
|
|
4
|
-
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.
|
|
3
|
+
import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.5lgR0kvt.js';
|
|
4
|
+
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.Borgldul.js';
|
|
5
5
|
import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
|
|
6
6
|
import { T as Traces } from './traces.CCmnQaNT.js';
|
|
7
7
|
import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
|
|
8
|
-
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.
|
|
8
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.BdSYEN5x.js';
|
|
9
9
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
10
10
|
import { startTests, collectTests } from '@vitest/runner';
|
|
11
|
-
import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.
|
|
12
|
-
import { g as globalExpect, v as vi } from './test.
|
|
11
|
+
import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.z3ZfZiWN.js';
|
|
12
|
+
import { g as globalExpect, v as vi } from './test.PnxXDGpZ.js';
|
|
13
13
|
import { c as closeInspector } from './inspector.CvyFGlXm.js';
|
|
14
14
|
import { createRequire } from 'node:module';
|
|
15
15
|
import timers from 'node:timers';
|
|
16
16
|
import timersPromises from 'node:timers/promises';
|
|
17
17
|
import util from 'node:util';
|
|
18
18
|
import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
|
|
19
|
-
import { i as index } from './index.
|
|
19
|
+
import { i as index } from './index.IcAjQV7n.js';
|
|
20
20
|
import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.BX5Fg8C4.js';
|
|
21
21
|
|
|
22
22
|
// this should only be used in Node
|
|
@@ -58,7 +58,7 @@ function resolveAsset(mod, url) {
|
|
|
58
58
|
mod.exports = url;
|
|
59
59
|
}
|
|
60
60
|
async function setupConsoleLogSpy() {
|
|
61
|
-
const { createCustomConsole } = await import('./console.
|
|
61
|
+
const { createCustomConsole } = await import('./console.3WNpx0tS.js');
|
|
62
62
|
globalThis.console = createCustomConsole();
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -115,7 +115,7 @@ async function startModuleRunner(options) {
|
|
|
115
115
|
let mocker;
|
|
116
116
|
if (options.state.config.experimental.nodeLoader !== false) {
|
|
117
117
|
// this additionally imports acorn/magic-string
|
|
118
|
-
const { NativeModuleMocker } = await import('./nativeModuleMocker.
|
|
118
|
+
const { NativeModuleMocker } = await import('./nativeModuleMocker.wQT5wU7r.js');
|
|
119
119
|
mocker = new NativeModuleMocker({
|
|
120
120
|
async resolveId(id, importer) {
|
|
121
121
|
// TODO: use import.meta.resolve instead
|
|
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
|
|
|
3
3
|
import { normalize } from 'pathe';
|
|
4
4
|
import c$2 from 'tinyrainbow';
|
|
5
5
|
import { b as defaultPort, d as defaultBrowserPort } from './constants.CPYnjOGj.js';
|
|
6
|
-
import { R as ReportersMap } from './index.
|
|
6
|
+
import { R as ReportersMap } from './index.DpkD7Zj4.js';
|
|
7
7
|
import assert from 'node:assert';
|
|
8
8
|
|
|
9
9
|
function toArr(any) {
|
|
@@ -620,7 +620,7 @@ class CAC extends EventEmitter {
|
|
|
620
620
|
|
|
621
621
|
const cac = (name = "") => new CAC(name);
|
|
622
622
|
|
|
623
|
-
var version = "4.1.0-beta.
|
|
623
|
+
var version = "4.1.0-beta.6";
|
|
624
624
|
|
|
625
625
|
const apiConfig = (port) => ({
|
|
626
626
|
port: {
|
|
@@ -2312,11 +2312,11 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
2312
2312
|
}
|
|
2313
2313
|
async function start(mode, cliFilters, options) {
|
|
2314
2314
|
try {
|
|
2315
|
-
const { startVitest } = await import('./cli-api.
|
|
2315
|
+
const { startVitest } = await import('./cli-api.Bqj5xGy5.js').then(function (n) { return n.q; });
|
|
2316
2316
|
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
2317
2317
|
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
2318
2318
|
} catch (e) {
|
|
2319
|
-
const { errorBanner } = await import('./index.
|
|
2319
|
+
const { errorBanner } = await import('./index.DpkD7Zj4.js').then(function (n) { return n.A; });
|
|
2320
2320
|
console.error(`\n${errorBanner("Startup Error")}`);
|
|
2321
2321
|
console.error(e);
|
|
2322
2322
|
console.error("\n\n");
|
|
@@ -2334,7 +2334,7 @@ async function init(project) {
|
|
|
2334
2334
|
}
|
|
2335
2335
|
async function collect(mode, cliFilters, options) {
|
|
2336
2336
|
try {
|
|
2337
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.
|
|
2337
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.Bqj5xGy5.js').then(function (n) { return n.q; });
|
|
2338
2338
|
const ctx = await prepareVitest(mode, {
|
|
2339
2339
|
...normalizeCliOptions(cliFilters, options),
|
|
2340
2340
|
watch: false,
|
|
@@ -2356,7 +2356,7 @@ async function collect(mode, cliFilters, options) {
|
|
|
2356
2356
|
} else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
|
|
2357
2357
|
await ctx.close();
|
|
2358
2358
|
} catch (e) {
|
|
2359
|
-
const { errorBanner } = await import('./index.
|
|
2359
|
+
const { errorBanner } = await import('./index.DpkD7Zj4.js').then(function (n) { return n.A; });
|
|
2360
2360
|
console.error(`\n${errorBanner("Collect Error")}`);
|
|
2361
2361
|
console.error(e);
|
|
2362
2362
|
console.error("\n\n");
|
|
@@ -12,9 +12,10 @@ import * as nodeos from 'node:os';
|
|
|
12
12
|
import nodeos__default, { tmpdir } from 'node:os';
|
|
13
13
|
import { generateHash as generateHash$1, createTaskName, validateTags, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, getTasks, isTestCase } from '@vitest/runner/utils';
|
|
14
14
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
15
|
-
import {
|
|
15
|
+
import { serializeValue } from '@vitest/utils/serialize';
|
|
16
|
+
import { v as version$1 } from './cac.Vtz91O0H.js';
|
|
16
17
|
import { rootDir, distDir } from '../path.js';
|
|
17
|
-
import { d as createIndexLocationsMap, e as TraceMap, o as originalPositionFor, h as ancestor, i as stringify, p as parse, j as printError, f as formatProjectName, w as withLabel, k as errorBanner, l as divider, m as Typechecker, n as generateCodeFrame, q as escapeRegExp, r as createDefinesScript, R as ReportersMap, u as groupBy, B as BlobReporter, v as readBlobs, x as convertTasksToEvents, H as HangingProcessReporter, y as wildcardPatternToRegExp, z as stdout } from './index.
|
|
18
|
+
import { d as createIndexLocationsMap, e as TraceMap, o as originalPositionFor, h as ancestor, i as stringify, p as parse, j as printError, f as formatProjectName, w as withLabel, k as errorBanner, l as divider, m as Typechecker, n as generateCodeFrame, q as escapeRegExp, r as createDefinesScript, R as ReportersMap, u as groupBy, B as BlobReporter, v as readBlobs, x as convertTasksToEvents, H as HangingProcessReporter, y as wildcardPatternToRegExp, z as stdout } from './index.DpkD7Zj4.js';
|
|
18
19
|
import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
|
|
19
20
|
import { T as Traces } from './traces.CCmnQaNT.js';
|
|
20
21
|
import { createDebug } from 'obug';
|
|
@@ -54,9 +55,8 @@ import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
|
|
|
54
55
|
import { KNOWN_ASSET_RE } from '@vitest/utils/constants';
|
|
55
56
|
import { findNearestPackageData } from '@vitest/utils/resolver';
|
|
56
57
|
import * as esModuleLexer from 'es-module-lexer';
|
|
57
|
-
import { a as BenchmarkReportsMap } from './index.
|
|
58
|
+
import { a as BenchmarkReportsMap } from './index.CHsi7RlU.js';
|
|
58
59
|
import assert$1 from 'node:assert';
|
|
59
|
-
import { serializeValue } from '@vitest/utils/serialize';
|
|
60
60
|
import { parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
61
61
|
import { extractSourcemapFromFile } from '@vitest/utils/source-map/node';
|
|
62
62
|
import readline from 'node:readline';
|
|
@@ -11010,7 +11010,8 @@ function generateHash(str) {
|
|
|
11010
11010
|
// vite.config.*
|
|
11011
11011
|
// vitest.unit.config.*
|
|
11012
11012
|
// vite.unit.config.*
|
|
11013
|
-
|
|
11013
|
+
// vitest.unit-test.config.*
|
|
11014
|
+
const CONFIG_REGEXP = /^vite(?:st)?(?:\.[\w-]+)?\.config\./;
|
|
11014
11015
|
async function resolveProjects(vitest, cliOptions, workspaceConfigPath, projectsDefinition, names) {
|
|
11015
11016
|
const { configFiles, projectConfigs, nonConfigDirectories } = await resolveTestProjectConfigs(vitest, workspaceConfigPath, projectsDefinition);
|
|
11016
11017
|
const cliOverrides = [
|
|
@@ -13187,11 +13188,13 @@ class Vitest {
|
|
|
13187
13188
|
const specification = this.getProjectByName(file.projectName || "").createSpecification(file.filepath, void 0, file.pool);
|
|
13188
13189
|
specifications.push(specification);
|
|
13189
13190
|
}
|
|
13190
|
-
await this._testRun.start(specifications)
|
|
13191
|
+
await this._testRun.start(specifications);
|
|
13191
13192
|
await this.coverageProvider?.onTestRunStart?.();
|
|
13192
13193
|
for (const file of files) await this._reportFileTask(file);
|
|
13193
|
-
|
|
13194
|
-
|
|
13194
|
+
// append errors thrown during reporter event replay during merge reports
|
|
13195
|
+
const unhandledErrors = [...errors, ...this.state.getUnhandledErrors()];
|
|
13196
|
+
this._checkUnhandledErrors(unhandledErrors);
|
|
13197
|
+
await this._testRun.end(specifications, unhandledErrors);
|
|
13195
13198
|
await this.initCoverageProvider();
|
|
13196
13199
|
await this.coverageProvider?.mergeReports?.(coverages);
|
|
13197
13200
|
return {
|
|
@@ -13209,15 +13212,23 @@ class Vitest {
|
|
|
13209
13212
|
/** @internal */
|
|
13210
13213
|
async _reportFileTask(file) {
|
|
13211
13214
|
const project = this.getProjectByName(file.projectName || "");
|
|
13212
|
-
await this._testRun.enqueued(project, file).catch(
|
|
13213
|
-
|
|
13215
|
+
await this._testRun.enqueued(project, file).catch((error) => {
|
|
13216
|
+
this.state.catchError(serializeValue(error), "Unhandled Reporter Error");
|
|
13217
|
+
});
|
|
13218
|
+
await this._testRun.collected(project, [file]).catch((error) => {
|
|
13219
|
+
this.state.catchError(serializeValue(error), "Unhandled Reporter Error");
|
|
13220
|
+
});
|
|
13214
13221
|
const logs = [];
|
|
13215
13222
|
const { packs, events } = convertTasksToEvents(file, (task) => {
|
|
13216
13223
|
if (task.logs) logs.push(...task.logs);
|
|
13217
13224
|
});
|
|
13218
13225
|
logs.sort((log1, log2) => log1.time - log2.time);
|
|
13219
|
-
for (const log of logs) await this._testRun.log(log).catch(
|
|
13220
|
-
|
|
13226
|
+
for (const log of logs) await this._testRun.log(log).catch((error) => {
|
|
13227
|
+
this.state.catchError(serializeValue(error), "Unhandled Reporter Error");
|
|
13228
|
+
});
|
|
13229
|
+
await this._testRun.updated(packs, events).catch((error) => {
|
|
13230
|
+
this.state.catchError(serializeValue(error), "Unhandled Reporter Error");
|
|
13231
|
+
});
|
|
13221
13232
|
}
|
|
13222
13233
|
async collect(filters, options) {
|
|
13223
13234
|
return this._traces.$("vitest.collect", async (collectSpan) => {
|
|
@@ -3,7 +3,7 @@ import { relative } from 'node:path';
|
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
4
|
import { getSafeTimers } from '@vitest/utils/timers';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import { R as RealDate } from './rpc.
|
|
6
|
+
import { R as RealDate } from './rpc.MzXet3jl.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.BX5Fg8C4.js';
|
|
8
8
|
import './index.Chj8NDwU.js';
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.CPYnjOGj.js';
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './test.
|
|
2
|
+
import { i as index } from './index.IcAjQV7n.js';
|
|
3
|
+
import './test.PnxXDGpZ.js';
|
|
4
4
|
import '@vitest/runner';
|
|
5
5
|
import '@vitest/utils/helpers';
|
|
6
6
|
import '@vitest/utils/timers';
|
|
@@ -15,7 +15,7 @@ import '@vitest/spy';
|
|
|
15
15
|
import '@vitest/utils/offset';
|
|
16
16
|
import '@vitest/utils/source-map';
|
|
17
17
|
import './_commonjsHelpers.D26ty3Ew.js';
|
|
18
|
-
import './rpc.
|
|
18
|
+
import './rpc.MzXet3jl.js';
|
|
19
19
|
import './index.Chj8NDwU.js';
|
|
20
20
|
import './evaluatedModules.Dg1zASAC.js';
|
|
21
21
|
import 'vite/module-runner';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { chai } from '@vitest/expect';
|
|
2
2
|
import { createHook } from 'node:async_hooks';
|
|
3
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.
|
|
4
|
-
import { r as rpc } from './rpc.
|
|
3
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.z3ZfZiWN.js';
|
|
4
|
+
import { r as rpc } from './rpc.MzXet3jl.js';
|
|
5
5
|
import { g as getWorkerState } from './utils.BX5Fg8C4.js';
|
|
6
|
-
import { T as TestRunner, N as NodeBenchmarkRunner } from './test.
|
|
6
|
+
import { T as TestRunner, N as NodeBenchmarkRunner } from './test.PnxXDGpZ.js';
|
|
7
7
|
|
|
8
8
|
function setupChaiConfig(config) {
|
|
9
9
|
Object.assign(chai.config, config);
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
|
-
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.
|
|
5
|
+
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.DpkD7Zj4.js';
|
|
6
6
|
import { stripVTControlCharacters } from 'node:util';
|
|
7
7
|
import { notNullish } from '@vitest/utils/helpers';
|
|
8
8
|
|