vitest 5.0.0-beta.2 → 5.0.0-beta.4
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/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{base.Opc_YHkk.js → base.BEGVMQrS.js} +6 -6
- package/dist/chunks/{browser.d.BUhkKcDl.d.ts → browser.d.BGxB4Xum.d.ts} +5 -26
- package/dist/chunks/{cac.8N4bOkkB.js → cac.CyXAEMkE.js} +26 -33
- package/dist/chunks/{cli-api.B0RFke2g.js → cli-api.DJMXq34b.js} +640 -615
- package/dist/chunks/{config.d.D91DHYaD.d.ts → config.d.DXq1aBpy.d.ts} +93 -89
- package/dist/chunks/{creator.BqL2U_x4.js → creator.D66cVXYh.js} +2 -2
- package/dist/chunks/{defaults.szbHWQun.js → defaults.CUUnbOrq.js} +6 -4
- package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
- package/dist/chunks/global.d.BtKPuz2X.d.ts +194 -0
- package/dist/chunks/{globals.EHmmu0nC.js → globals.BuY-yD0m.js} +2 -1
- package/dist/chunks/{index.D_7-4CaB.js → index.CE58PZNH.js} +1660 -701
- package/dist/chunks/{index.CViWo__T.js → index.CcluKS59.js} +4 -4
- package/dist/chunks/{index.CbgUM9E5.js → index.nQFVd50u.js} +2 -1
- package/dist/chunks/{init-forks.DMge3WTt.js → init-forks.Ce3vGWgL.js} +1 -1
- package/dist/chunks/{init-threads.eIoyCTon.js → init-threads.8e1OLv5v.js} +1 -1
- package/dist/chunks/{init.BVd7SaCA.js → init.6qx-LaHs.js} +31 -3
- package/dist/chunks/{nativeModuleMocker.DKpFw0pk.js → nativeModuleMocker.DDZfQXLs.js} +1 -1
- package/dist/chunks/{plugin.d.cIKZEZ16.d.ts → plugin.d.B7MTG_Fe.d.ts} +103 -88
- package/dist/chunks/{rpc.d.7JZuxZ8u.d.ts → rpc.d.OQ_EZi1Z.d.ts} +18 -2
- package/dist/chunks/{setup-common.Hpq30zVk.js → setup-common.DdEF_hkE.js} +1 -1
- package/dist/chunks/{vm.2okbRRME.js → vm.Bu7mmcZq.js} +2 -2
- package/dist/chunks/{worker.d.Bu1kXGw4.d.ts → worker.d.yR22cs6X.d.ts} +3 -2
- package/dist/cli.js +2 -2
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +7 -10
- package/dist/config.js +2 -2
- package/dist/index.d.ts +24 -41
- package/dist/index.js +2 -1
- package/dist/module-evaluator.d.ts +4 -1
- package/dist/module-evaluator.js +15 -20
- package/dist/node.d.ts +20 -13
- package/dist/node.js +6 -6
- package/dist/runtime.js +2 -2
- package/dist/worker.d.ts +3 -3
- package/dist/worker.js +7 -6
- package/dist/workers/forks.js +8 -7
- package/dist/workers/runVmTests.js +4 -3
- package/dist/workers/threads.js +8 -7
- package/dist/workers/vmForks.js +4 -4
- package/dist/workers/vmThreads.js +4 -4
- package/package.json +20 -21
- package/dist/chunks/global.d.DhbKSQoV.d.ts +0 -99
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.
|
|
1
|
+
import { c as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.DXq1aBpy.js';
|
|
2
2
|
import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.g2xbl2sP.js';
|
|
3
3
|
import { SerializedDiffOptions } from '@vitest/utils/diff';
|
|
4
4
|
export { collectTests, startTests } from '@vitest/runner';
|
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.DdEF_hkE.js';
|
|
2
2
|
export { collectTests, startTests } from '@vitest/runner';
|
|
3
3
|
import * as spyModule from '@vitest/spy';
|
|
4
4
|
export { spyModule as SpyModule };
|
|
@@ -1,15 +1,15 @@
|
|
|
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.CcluKS59.js';
|
|
4
|
+
import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.6qx-LaHs.js';
|
|
5
5
|
import { N as NativeModuleRunner } from './nativeModuleRunner.BOeMnHl4.js';
|
|
6
6
|
import { Traces } from '../traces.js';
|
|
7
7
|
import { V as VitestEvaluatedModules } from './rpc.DFRWVnRh.js';
|
|
8
|
-
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.
|
|
8
|
+
import { s as startVitestModuleRunner, c as createNodeImportMeta } from './index.nQFVd50u.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 { i as index, g as globalExpect, v as vi } from './index.
|
|
11
|
+
import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.DdEF_hkE.js';
|
|
12
|
+
import { i as index, g as globalExpect, v as vi } from './index.CE58PZNH.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';
|
|
@@ -114,7 +114,7 @@ async function startModuleRunner(options) {
|
|
|
114
114
|
let mocker;
|
|
115
115
|
if (options.state.config.experimental.nodeLoader !== false) {
|
|
116
116
|
// this additionally imports acorn/magic-string
|
|
117
|
-
const { NativeModuleMocker } = await import('./nativeModuleMocker.
|
|
117
|
+
const { NativeModuleMocker } = await import('./nativeModuleMocker.DDZfQXLs.js');
|
|
118
118
|
mocker = new NativeModuleMocker({
|
|
119
119
|
async resolveId(id, importer) {
|
|
120
120
|
// TODO: use import.meta.resolve instead
|
|
@@ -2,11 +2,9 @@ import { MockInstance } from '@vitest/spy';
|
|
|
2
2
|
import { Formatter } from 'tinyrainbow';
|
|
3
3
|
import { diff, printDiffOrStringify } from '@vitest/utils/diff';
|
|
4
4
|
import { stringify } from '@vitest/utils/display';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { O as OTELCarrier } from './rpc.d.7JZuxZ8u.js';
|
|
9
|
-
import { T as TestExecutionMethod } from './worker.d.Bu1kXGw4.js';
|
|
5
|
+
import { FileSpecification } from '@vitest/runner';
|
|
6
|
+
import { O as OTELCarrier } from './rpc.d.OQ_EZi1Z.js';
|
|
7
|
+
import { T as TestExecutionMethod } from './worker.d.yR22cs6X.js';
|
|
10
8
|
|
|
11
9
|
type SerializedTestSpecification = [project: {
|
|
12
10
|
name: string | undefined;
|
|
@@ -200,7 +198,7 @@ interface CustomMatcher {
|
|
|
200
198
|
* expect('foo').toBeOneOf([expect.any(String)])
|
|
201
199
|
* expect({ a: 1 }).toEqual({ a: expect.toBeOneOf(['1', '2', '3']) })
|
|
202
200
|
*/
|
|
203
|
-
toBeOneOf: <T>(sample:
|
|
201
|
+
toBeOneOf: <T>(sample: ReadonlyArray<T> | ReadonlySet<T>) => any;
|
|
204
202
|
}
|
|
205
203
|
interface AsymmetricMatchersContaining extends CustomMatcher {
|
|
206
204
|
/**
|
|
@@ -870,25 +868,6 @@ declare global {
|
|
|
870
868
|
}
|
|
871
869
|
}
|
|
872
870
|
|
|
873
|
-
interface Benchmark extends Test {
|
|
874
|
-
meta: {
|
|
875
|
-
benchmark: true;
|
|
876
|
-
result?: TaskResult;
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
interface BenchmarkResult extends TaskResult {
|
|
880
|
-
name: string;
|
|
881
|
-
rank: number;
|
|
882
|
-
sampleCount: number;
|
|
883
|
-
median: number;
|
|
884
|
-
}
|
|
885
|
-
type BenchFunction = (this: Bench) => Promise<void> | void;
|
|
886
|
-
type ChainableBenchmarkAPI = ChainableFunction<"skip" | "only" | "todo", (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
|
|
887
|
-
type BenchmarkAPI = ChainableBenchmarkAPI & {
|
|
888
|
-
skipIf: (condition: any) => ChainableBenchmarkAPI;
|
|
889
|
-
runIf: (condition: any) => ChainableBenchmarkAPI;
|
|
890
|
-
};
|
|
891
|
-
|
|
892
871
|
interface BrowserTesterOptions {
|
|
893
872
|
method: TestExecutionMethod;
|
|
894
873
|
files: FileSpecification[];
|
|
@@ -896,4 +875,4 @@ interface BrowserTesterOptions {
|
|
|
896
875
|
otelCarrier?: OTELCarrier;
|
|
897
876
|
}
|
|
898
877
|
|
|
899
|
-
export type { AsyncExpectationResult as A,
|
|
878
|
+
export type { AsyncExpectationResult as A, BrowserTesterOptions as B, DeeplyAllowMatchers as D, ExpectStatic as E, JestAssertion as J, ModuleDefinitionDurationsDiagnostic as M, PromisifyAssertion as P, RawMatcherFn as R, SerializedTestSpecification as S, Tester as T, UntrackedModuleDefinitionDiagnostic as U, MatcherState as a, SyncExpectationResult as b, ExpectationResult as c, ModuleDefinitionDiagnostic as d, ModuleDefinitionLocation as e, SourceModuleDiagnostic as f, SourceModuleLocations as g, Assertion as h, AsymmetricMatchersContaining as i, Matchers as j, MatchersObject as k };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { toArray } from '@vitest/utils/helpers';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { normalize } from 'pathe';
|
|
4
|
-
import
|
|
5
|
-
import './env.
|
|
4
|
+
import { disableDefaultColors } from 'tinyrainbow';
|
|
5
|
+
import { i as isForceColor } from './env.BKKtU2WC.js';
|
|
6
6
|
import { a as defaultPort, d as defaultBrowserPort } from './constants.-juJ8b_4.js';
|
|
7
7
|
import assert from 'node:assert';
|
|
8
8
|
import { isAgent } from 'std-env';
|
|
@@ -621,7 +621,7 @@ class CAC extends EventEmitter {
|
|
|
621
621
|
|
|
622
622
|
const cac = (name = "") => new CAC(name);
|
|
623
623
|
|
|
624
|
-
var version = "5.0.0-beta.
|
|
624
|
+
var version = "5.0.0-beta.4";
|
|
625
625
|
|
|
626
626
|
const apiConfig = (port) => ({
|
|
627
627
|
port: {
|
|
@@ -839,7 +839,7 @@ const cliOptionsConfig = {
|
|
|
839
839
|
}
|
|
840
840
|
},
|
|
841
841
|
mode: {
|
|
842
|
-
description: "Override Vite mode (default: `test`
|
|
842
|
+
description: "Override Vite mode (default: `test`)",
|
|
843
843
|
argument: "<name>"
|
|
844
844
|
},
|
|
845
845
|
isolate: { description: "Run every test file in isolation. To disable isolation, use `--no-isolate` (default: `true`)" },
|
|
@@ -907,7 +907,8 @@ const cliOptionsConfig = {
|
|
|
907
907
|
argument: "<options>",
|
|
908
908
|
subcommands: {
|
|
909
909
|
testIdAttribute: null,
|
|
910
|
-
exact: { description: "Should locators match the text exactly by default (default: `
|
|
910
|
+
exact: { description: "Should locators match the text exactly by default (default: `true`)" },
|
|
911
|
+
errorFormat: null
|
|
911
912
|
},
|
|
912
913
|
transform(val) {
|
|
913
914
|
if (typeof val !== "object" || val == null) return {};
|
|
@@ -1109,6 +1110,7 @@ const cliOptionsConfig = {
|
|
|
1109
1110
|
},
|
|
1110
1111
|
allowJs: { description: "Allow JavaScript files to be typechecked. By default takes the value from tsconfig.json" },
|
|
1111
1112
|
ignoreSourceErrors: { description: "Ignore type errors from source files" },
|
|
1113
|
+
build: { description: "Use TypeScript build mode" },
|
|
1112
1114
|
tsconfig: {
|
|
1113
1115
|
description: "Path to a custom tsconfig file",
|
|
1114
1116
|
argument: "<path>",
|
|
@@ -1296,8 +1298,6 @@ const cliOptionsConfig = {
|
|
|
1296
1298
|
deps: null,
|
|
1297
1299
|
name: null,
|
|
1298
1300
|
snapshotEnvironment: null,
|
|
1299
|
-
compare: null,
|
|
1300
|
-
outputJson: null,
|
|
1301
1301
|
json: null,
|
|
1302
1302
|
provide: null,
|
|
1303
1303
|
filesOnly: null,
|
|
@@ -1306,18 +1306,9 @@ const cliOptionsConfig = {
|
|
|
1306
1306
|
projects: null,
|
|
1307
1307
|
watchTriggerPatterns: null,
|
|
1308
1308
|
tags: null,
|
|
1309
|
+
benchmarkOnly: null,
|
|
1309
1310
|
taskTitleValueFormatTruncate: null
|
|
1310
1311
|
};
|
|
1311
|
-
const benchCliOptionsConfig = {
|
|
1312
|
-
compare: {
|
|
1313
|
-
description: "Benchmark output file to compare against",
|
|
1314
|
-
argument: "<filename>"
|
|
1315
|
-
},
|
|
1316
|
-
outputJson: {
|
|
1317
|
-
description: "Benchmark output file",
|
|
1318
|
-
argument: "<filename>"
|
|
1319
|
-
}
|
|
1320
|
-
};
|
|
1321
1312
|
const collectCliOptionsConfig = {
|
|
1322
1313
|
...cliOptionsConfig,
|
|
1323
1314
|
json: {
|
|
@@ -2225,7 +2216,7 @@ function addCliOptions(cli, options) {
|
|
|
2225
2216
|
for (const [optionName, option] of Object.entries(options)) if (option) addCommand(cli, optionName, option);
|
|
2226
2217
|
}
|
|
2227
2218
|
function createCLI(options = {}) {
|
|
2228
|
-
if (isAgent) disableDefaultColors();
|
|
2219
|
+
if (isAgent && !isForceColor()) disableDefaultColors();
|
|
2229
2220
|
const cli = cac("vitest");
|
|
2230
2221
|
cli.version(version);
|
|
2231
2222
|
addCliOptions(cli, cliOptionsConfig);
|
|
@@ -2274,10 +2265,10 @@ function createCLI(options = {}) {
|
|
|
2274
2265
|
cli.command("related [...filters]", void 0, options).action(runRelated);
|
|
2275
2266
|
cli.command("watch [...filters]", void 0, options).action(watch);
|
|
2276
2267
|
cli.command("dev [...filters]", void 0, options).action(watch);
|
|
2277
|
-
|
|
2268
|
+
cli.command("bench [...filters]", void 0, options).action(benchmark);
|
|
2278
2269
|
cli.command("init <project>", void 0, options).action(init);
|
|
2279
|
-
addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect(
|
|
2280
|
-
cli.command("[...filters]", void 0, options).action((filters, options) => start(
|
|
2270
|
+
addCliOptions(cli.command("list [...filters]", void 0, options).action((filters, options) => collect(filters, options)), collectCliOptionsConfig);
|
|
2271
|
+
cli.command("[...filters]", void 0, options).action((filters, options) => start(filters, options));
|
|
2281
2272
|
setupTabCompletions(cli);
|
|
2282
2273
|
return cli;
|
|
2283
2274
|
}
|
|
@@ -2318,20 +2309,22 @@ function parseCLI(argv, config = {}) {
|
|
|
2318
2309
|
async function runRelated(relatedFiles, argv) {
|
|
2319
2310
|
argv.related = relatedFiles;
|
|
2320
2311
|
argv.passWithNoTests ??= true;
|
|
2321
|
-
await start(
|
|
2312
|
+
await start([], argv);
|
|
2322
2313
|
}
|
|
2323
2314
|
async function watch(cliFilters, options) {
|
|
2324
2315
|
options.watch = true;
|
|
2325
|
-
await start(
|
|
2316
|
+
await start(cliFilters, options);
|
|
2326
2317
|
}
|
|
2327
2318
|
async function run(cliFilters, options) {
|
|
2328
2319
|
// "vitest run --watch" should still be watch mode
|
|
2329
2320
|
options.run = !options.watch;
|
|
2330
|
-
await start(
|
|
2321
|
+
await start(cliFilters, options);
|
|
2331
2322
|
}
|
|
2332
2323
|
async function benchmark(cliFilters, options) {
|
|
2333
|
-
|
|
2334
|
-
|
|
2324
|
+
options.benchmarkOnly = true;
|
|
2325
|
+
options.coverage ??= {};
|
|
2326
|
+
options.coverage.enabled = false;
|
|
2327
|
+
await start(cliFilters, options);
|
|
2335
2328
|
}
|
|
2336
2329
|
function normalizeCliOptions(cliFilters, argv) {
|
|
2337
2330
|
if (argv.exclude) {
|
|
@@ -2346,10 +2339,10 @@ function normalizeCliOptions(cliFilters, argv) {
|
|
|
2346
2339
|
}
|
|
2347
2340
|
return argv;
|
|
2348
2341
|
}
|
|
2349
|
-
async function start(
|
|
2342
|
+
async function start(cliFilters, options) {
|
|
2350
2343
|
try {
|
|
2351
|
-
const { startVitest } = await import('./cli-api.
|
|
2352
|
-
const ctx = await startVitest(
|
|
2344
|
+
const { startVitest } = await import('./cli-api.DJMXq34b.js').then(function (n) { return n.C; });
|
|
2345
|
+
const ctx = await startVitest(cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
|
|
2353
2346
|
if (!ctx.shouldKeepServer()) await ctx.exit();
|
|
2354
2347
|
} catch (e) {
|
|
2355
2348
|
const { errorBanner } = await import('./utils.DKODp04v.js').then(function (n) { return n.u; });
|
|
@@ -2365,13 +2358,13 @@ async function init(project) {
|
|
|
2365
2358
|
console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
|
|
2366
2359
|
process.exit(1);
|
|
2367
2360
|
}
|
|
2368
|
-
const { create } = await import('./creator.
|
|
2361
|
+
const { create } = await import('./creator.D66cVXYh.js');
|
|
2369
2362
|
await create();
|
|
2370
2363
|
}
|
|
2371
|
-
async function collect(
|
|
2364
|
+
async function collect(cliFilters, options) {
|
|
2372
2365
|
try {
|
|
2373
|
-
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.
|
|
2374
|
-
const ctx = await prepareVitest(
|
|
2366
|
+
const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.DJMXq34b.js').then(function (n) { return n.C; });
|
|
2367
|
+
const ctx = await prepareVitest({
|
|
2375
2368
|
...normalizeCliOptions(cliFilters, options),
|
|
2376
2369
|
watch: false,
|
|
2377
2370
|
run: true
|