vitest 3.0.0-beta.4 → 3.0.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/dist/browser.d.ts +2 -2
- package/dist/browser.js +1 -1
- package/dist/chunks/{base.BJ8KO-VX.js → base.gZAre3Yy.js} +3 -3
- package/dist/chunks/{cac.BAYqQ2aM.js → cac.Davy6Tyx.js} +24 -24
- package/dist/chunks/{cli-api.Dhl34Trr.js → cli-api.DO-hp2Kx.js} +1031 -162
- package/dist/chunks/{console.CN7AiMGV.js → console.BxE0RUCr.js} +3 -3
- package/dist/chunks/{creator.Ot9GlSGw.js → creator.B8v1wNyQ.js} +3 -3
- package/dist/chunks/{execute.BMOaRArH.js → execute.4vt3NSmG.js} +3 -4
- package/dist/chunks/global.CnI8_G5V.d.ts +133 -0
- package/dist/chunks/{globals.C5RQxaV3.js → globals.BSNBk3vE.js} +2 -2
- package/dist/chunks/{index.BQbxGbG9.js → index.Bf4FgyZN.js} +1 -1
- package/dist/chunks/{index.BJDntFik.js → index.Bh7wTRhh.js} +8 -8
- package/dist/chunks/{index.B2M9nD1V.js → index.C2XSkjNu.js} +5 -5
- package/dist/chunks/{index.DQboAxJm.js → index.DfqWks-F.js} +2 -1
- package/dist/chunks/{index.CAueP3cK.js → index.DyQPL4DO.js} +200 -945
- package/dist/chunks/{index.68735LiX.js → index.TH3f4LSA.js} +2 -2
- package/dist/chunks/{index.K90BXFOx.js → index.cYxyd29h.js} +12 -12
- package/dist/chunks/{inspector.DKLceBVD.js → inspector.CU9GlB9I.js} +1 -1
- package/dist/chunks/{reporters.Dcdq51WE.d.ts → reporters.Y8BYiXBN.d.ts} +340 -239
- package/dist/chunks/{resolveConfig.kZFMjKCQ.js → resolveConfig.DATSOo7x.js} +150 -65
- package/dist/chunks/{rpc.C3q9uwRX.js → rpc.Bf456uf4.js} +1 -2
- package/dist/chunks/{runBaseTests.URiUrnWK.js → runBaseTests.Ba8jtu6O.js} +8 -8
- package/dist/chunks/{setup-common.D0zLenuv.js → setup-common.jLbIuaww.js} +1 -1
- package/dist/chunks/{RandomSequencer.DB__To1b.js → typechecker.ChNaIV36.js} +62 -115
- package/dist/chunks/{utils.yHKcm4dz.js → utils.DJWL04yX.js} +1 -1
- package/dist/chunks/{vi.Da_PT3Vw.js → vi.CjhMlMwf.js} +6 -6
- package/dist/chunks/{vite.DzluO1Kj.d.ts → vite.CQ0dHgkN.d.ts} +1 -1
- package/dist/chunks/{vm.DrFVeTXo.js → vm.CUw7ChSp.js} +5 -5
- package/dist/chunks/{worker.BIVMnzXw.d.ts → worker.B1y96qmv.d.ts} +1 -1
- package/dist/chunks/{worker.Hz_LAzfd.d.ts → worker.CIpff8Eg.d.ts} +2 -4
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +12 -11
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +17 -118
- package/dist/index.js +2 -2
- package/dist/node.d.ts +11 -8
- package/dist/node.js +27 -25
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -6
- package/dist/runners.d.ts +1 -0
- package/dist/runners.js +10 -10
- package/dist/worker.js +5 -5
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +7 -7
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +3 -3
- package/dist/workers/vmThreads.js +3 -3
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +8 -8
- package/package.json +17 -17
- package/dist/chunks/types.BOjykUpq.d.ts +0 -27
|
@@ -121,7 +121,7 @@ function createCustomConsole(defaultState) {
|
|
|
121
121
|
Error.stackTraceLimit = limit;
|
|
122
122
|
buffer.push([data, trace]);
|
|
123
123
|
} else {
|
|
124
|
-
buffer.push([data,
|
|
124
|
+
buffer.push([data, undefined]);
|
|
125
125
|
}
|
|
126
126
|
schedule(id);
|
|
127
127
|
callback();
|
|
@@ -155,14 +155,14 @@ function createCustomConsole(defaultState) {
|
|
|
155
155
|
(line) => line.includes("at Console.trace")
|
|
156
156
|
);
|
|
157
157
|
if (isTrace) {
|
|
158
|
-
buffer.push([data,
|
|
158
|
+
buffer.push([data, undefined]);
|
|
159
159
|
} else {
|
|
160
160
|
const trace = stack?.slice(7).join("\n");
|
|
161
161
|
Error.stackTraceLimit = limit;
|
|
162
162
|
buffer.push([data, trace]);
|
|
163
163
|
}
|
|
164
164
|
} else {
|
|
165
|
-
buffer.push([data,
|
|
165
|
+
buffer.push([data, undefined]);
|
|
166
166
|
}
|
|
167
167
|
schedule(id);
|
|
168
168
|
callback();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, writeFileSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve, dirname, relative } from 'node:path';
|
|
4
|
-
import { detectPackageManager, installPackage } from './index.
|
|
5
|
-
import { p as prompt, f as findUp } from './index.
|
|
4
|
+
import { detectPackageManager, installPackage } from './index.DfqWks-F.js';
|
|
5
|
+
import { p as prompt, f as findUp } from './index.Bh7wTRhh.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
7
|
import c from 'tinyrainbow';
|
|
8
8
|
import { c as configFiles } from './constants.fzPh7AOq.js';
|
|
@@ -373,7 +373,7 @@ async function installPackages(pkgManager, packages) {
|
|
|
373
373
|
log(c.cyan("\u25FC"), c.bold("Installing packages..."));
|
|
374
374
|
log(c.cyan("\u25FC"), packages.join(", "));
|
|
375
375
|
log();
|
|
376
|
-
await installPackage(packages, { dev: true, packageManager: pkgManager ??
|
|
376
|
+
await installPackage(packages, { dev: true, packageManager: pkgManager ?? undefined });
|
|
377
377
|
}
|
|
378
378
|
function readPkgJson(path) {
|
|
379
379
|
if (!existsSync(path)) {
|
|
@@ -22,7 +22,6 @@ const _UNC_REGEX = /^[/\\]{2}/;
|
|
|
22
22
|
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
23
23
|
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
24
24
|
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
25
|
-
globalThis.process?.platform === "win32" ? ";" : ":";
|
|
26
25
|
const normalize = function(path) {
|
|
27
26
|
if (path.length === 0) {
|
|
28
27
|
return ".";
|
|
@@ -395,7 +394,7 @@ class VitestMocker {
|
|
|
395
394
|
}
|
|
396
395
|
} else if (!(prop in target)) {
|
|
397
396
|
if (this.filterPublicKeys.includes(prop)) {
|
|
398
|
-
return
|
|
397
|
+
return undefined;
|
|
399
398
|
}
|
|
400
399
|
throw this.createError(
|
|
401
400
|
`[vitest] No "${String(prop)}" export is defined on the "${mock.raw}" mock. Did you forget to return it from "vi.mock"?
|
|
@@ -538,7 +537,7 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
|
|
|
538
537
|
action: "mock",
|
|
539
538
|
id,
|
|
540
539
|
importer,
|
|
541
|
-
factory: typeof factoryOrOptions === "function" ? factoryOrOptions :
|
|
540
|
+
factory: typeof factoryOrOptions === "function" ? factoryOrOptions : undefined,
|
|
542
541
|
type: mockType
|
|
543
542
|
});
|
|
544
543
|
}
|
|
@@ -764,7 +763,7 @@ class VitestExecutor extends ViteNodeRunner {
|
|
|
764
763
|
const { id: id2 } = error[Symbol.for("vitest.error.not_found.data")];
|
|
765
764
|
const path = this.mocker.normalizePath(id2);
|
|
766
765
|
const mock = this.mocker.getDependencyMock(path);
|
|
767
|
-
if (mock !==
|
|
766
|
+
if (mock !== undefined) {
|
|
768
767
|
return [id2, id2];
|
|
769
768
|
}
|
|
770
769
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
|
|
2
|
+
import { Plugin } from '@vitest/pretty-format';
|
|
3
|
+
import { SnapshotState } from '@vitest/snapshot';
|
|
4
|
+
import { B as BenchmarkResult } from './benchmark.CFFwLv-O.js';
|
|
5
|
+
import { U as UserConsoleLog } from './environment.d8YfPkTm.js';
|
|
6
|
+
|
|
7
|
+
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
8
|
+
interface TscErrorInfo {
|
|
9
|
+
filePath: string;
|
|
10
|
+
errCode: number;
|
|
11
|
+
errMsg: string;
|
|
12
|
+
line: number;
|
|
13
|
+
column: number;
|
|
14
|
+
}
|
|
15
|
+
interface CollectLineNumbers {
|
|
16
|
+
target: number;
|
|
17
|
+
next: number;
|
|
18
|
+
prev?: number;
|
|
19
|
+
}
|
|
20
|
+
type CollectLines = {
|
|
21
|
+
[key in keyof CollectLineNumbers]: string;
|
|
22
|
+
};
|
|
23
|
+
interface RootAndTarget {
|
|
24
|
+
root: string;
|
|
25
|
+
targetAbsPath: string;
|
|
26
|
+
}
|
|
27
|
+
type Context = RootAndTarget & {
|
|
28
|
+
rawErrsMap: RawErrsMap;
|
|
29
|
+
openedDirs: Set<string>;
|
|
30
|
+
lastActivePath?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare global {
|
|
34
|
+
namespace Chai {
|
|
35
|
+
interface Assertion {
|
|
36
|
+
containSubset: (expected: any) => Assertion;
|
|
37
|
+
}
|
|
38
|
+
interface Assert {
|
|
39
|
+
containSubset: (val: any, exp: any, msg?: string) => void;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
interface SnapshotMatcher<T> {
|
|
44
|
+
<U extends {
|
|
45
|
+
[P in keyof T]: any;
|
|
46
|
+
}>(snapshot: Partial<U>, message?: string): void;
|
|
47
|
+
(message?: string): void;
|
|
48
|
+
}
|
|
49
|
+
interface InlineSnapshotMatcher<T> {
|
|
50
|
+
<U extends {
|
|
51
|
+
[P in keyof T]: any;
|
|
52
|
+
}>(properties: Partial<U>, snapshot?: string, message?: string): void;
|
|
53
|
+
(message?: string): void;
|
|
54
|
+
}
|
|
55
|
+
declare module '@vitest/expect' {
|
|
56
|
+
interface MatcherState {
|
|
57
|
+
environment: string;
|
|
58
|
+
snapshotState: SnapshotState;
|
|
59
|
+
}
|
|
60
|
+
interface ExpectPollOptions {
|
|
61
|
+
interval?: number;
|
|
62
|
+
timeout?: number;
|
|
63
|
+
message?: string;
|
|
64
|
+
}
|
|
65
|
+
interface ExpectStatic {
|
|
66
|
+
unreachable: (message?: string) => never;
|
|
67
|
+
soft: <T>(actual: T, message?: string) => Assertion<T>;
|
|
68
|
+
poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
|
|
69
|
+
addEqualityTesters: (testers: Array<Tester>) => void;
|
|
70
|
+
assertions: (expected: number) => void;
|
|
71
|
+
hasAssertions: () => void;
|
|
72
|
+
addSnapshotSerializer: (plugin: Plugin) => void;
|
|
73
|
+
}
|
|
74
|
+
interface Assertion<T> {
|
|
75
|
+
matchSnapshot: SnapshotMatcher<T>;
|
|
76
|
+
toMatchSnapshot: SnapshotMatcher<T>;
|
|
77
|
+
toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Checks that an error thrown by a function matches a previously recorded snapshot.
|
|
80
|
+
*
|
|
81
|
+
* @param message - Optional custom error message.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* expect(functionWithError).toThrowErrorMatchingSnapshot();
|
|
85
|
+
*/
|
|
86
|
+
toThrowErrorMatchingSnapshot: (message?: string) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Checks that an error thrown by a function matches an inline snapshot within the test file.
|
|
89
|
+
* Useful for keeping snapshots close to the test code.
|
|
90
|
+
*
|
|
91
|
+
* @param snapshot - Optional inline snapshot string to match.
|
|
92
|
+
* @param message - Optional custom error message.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* const throwError = () => { throw new Error('Error occurred') };
|
|
96
|
+
* expect(throwError).toThrowErrorMatchingInlineSnapshot(`"Error occurred"`);
|
|
97
|
+
*/
|
|
98
|
+
toThrowErrorMatchingInlineSnapshot: (snapshot?: string, message?: string) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Compares the received value to a snapshot saved in a specified file.
|
|
101
|
+
* Useful for cases where snapshot content is large or needs to be shared across tests.
|
|
102
|
+
*
|
|
103
|
+
* @param filepath - Path to the snapshot file.
|
|
104
|
+
* @param message - Optional custom error message.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json');
|
|
108
|
+
*/
|
|
109
|
+
toMatchFileSnapshot: (filepath: string, message?: string) => Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
declare module '@vitest/runner' {
|
|
113
|
+
interface TestContext {
|
|
114
|
+
expect: ExpectStatic;
|
|
115
|
+
}
|
|
116
|
+
interface TaskMeta {
|
|
117
|
+
typecheck?: boolean;
|
|
118
|
+
benchmark?: boolean;
|
|
119
|
+
failScreenshotPath?: string;
|
|
120
|
+
}
|
|
121
|
+
interface File {
|
|
122
|
+
prepareDuration?: number;
|
|
123
|
+
environmentLoad?: number;
|
|
124
|
+
}
|
|
125
|
+
interface TaskBase {
|
|
126
|
+
logs?: UserConsoleLog[];
|
|
127
|
+
}
|
|
128
|
+
interface TaskResult {
|
|
129
|
+
benchmark?: BenchmarkResult;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type { CollectLineNumbers as C, RawErrsMap as R, TscErrorInfo as T, CollectLines as a, RootAndTarget as b, Context as c };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.fzPh7AOq.js';
|
|
2
|
-
import { V as VitestIndex } from './index.
|
|
3
|
-
import './vi.
|
|
2
|
+
import { V as VitestIndex } from './index.Bf4FgyZN.js';
|
|
3
|
+
import './vi.CjhMlMwf.js';
|
|
4
4
|
import '@vitest/expect';
|
|
5
5
|
import '@vitest/runner';
|
|
6
6
|
import '@vitest/runner/utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.
|
|
1
|
+
import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.CjhMlMwf.js';
|
|
2
2
|
import { i as isFirstRun, a as runOnce } from './run-once.2ogXb3JV.js';
|
|
3
3
|
import { b as bench } from './benchmark.Cdu9hjj4.js';
|
|
4
4
|
import { expectTypeOf } from 'expect-type';
|
|
@@ -400,11 +400,11 @@ function requireKleur () {
|
|
|
400
400
|
rgx: new RegExp(`\\x1b\\[${close}m`, 'g')
|
|
401
401
|
};
|
|
402
402
|
return function (txt) {
|
|
403
|
-
if (this !==
|
|
403
|
+
if (this !== undefined && this.has !== undefined) {
|
|
404
404
|
this.has.includes(open) || (this.has.push(open),this.keys.push(blk));
|
|
405
|
-
return txt ===
|
|
405
|
+
return txt === undefined ? this : $.enabled ? run(this.keys, txt+'') : txt+'';
|
|
406
406
|
}
|
|
407
|
-
return txt ===
|
|
407
|
+
return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
|
|
@@ -816,7 +816,7 @@ function requirePrompt$1 () {
|
|
|
816
816
|
this.in = opts.stdin || process.stdin;
|
|
817
817
|
this.out = opts.stdout || process.stdout;
|
|
818
818
|
|
|
819
|
-
this.onRender = (opts.onRender || (() =>
|
|
819
|
+
this.onRender = (opts.onRender || (() => undefined)).bind(this);
|
|
820
820
|
|
|
821
821
|
const rl = readline.createInterface({
|
|
822
822
|
input: this.in,
|
|
@@ -2760,7 +2760,7 @@ function requireAutocomplete$1 () {
|
|
|
2760
2760
|
reset() {
|
|
2761
2761
|
this.input = '';
|
|
2762
2762
|
this.complete(() => {
|
|
2763
|
-
this.moveSelect(this.initial !==
|
|
2763
|
+
this.moveSelect(this.initial !== undefined ? this.initial : 0);
|
|
2764
2764
|
this.render();
|
|
2765
2765
|
});
|
|
2766
2766
|
this.render();
|
|
@@ -3973,7 +3973,7 @@ function requirePrompt () {
|
|
|
3973
3973
|
this.firstRender = true;
|
|
3974
3974
|
this.in = opts.stdin || process.stdin;
|
|
3975
3975
|
this.out = opts.stdout || process.stdout;
|
|
3976
|
-
this.onRender = (opts.onRender || (() =>
|
|
3976
|
+
this.onRender = (opts.onRender || (() => undefined)).bind(this);
|
|
3977
3977
|
const rl = readline.createInterface({ input:this.in, escapeCodeTimeout:50 });
|
|
3978
3978
|
readline.emitKeypressEvents(this.in, rl);
|
|
3979
3979
|
|
|
@@ -5735,7 +5735,7 @@ function requireAutocomplete () {
|
|
|
5735
5735
|
reset() {
|
|
5736
5736
|
this.input = '';
|
|
5737
5737
|
this.complete(() => {
|
|
5738
|
-
this.moveSelect(this.initial !==
|
|
5738
|
+
this.moveSelect(this.initial !== undefined ? this.initial : 0);
|
|
5739
5739
|
this.render();
|
|
5740
5740
|
});
|
|
5741
5741
|
this.render();
|
|
@@ -6502,7 +6502,7 @@ function requireLib () {
|
|
|
6502
6502
|
// update vars in case they changed
|
|
6503
6503
|
({ name, type } = question);
|
|
6504
6504
|
|
|
6505
|
-
if (prompts[type] ===
|
|
6505
|
+
if (prompts[type] === undefined) {
|
|
6506
6506
|
throw new Error(`prompt type (${type}) is not defined`);
|
|
6507
6507
|
}
|
|
6508
6508
|
|
|
@@ -2,8 +2,8 @@ import * as chai from 'chai';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { t as takeCoverageInsideWorker } from './coverage.BWeNbfBa.js';
|
|
4
4
|
import { distDir } from '../path.js';
|
|
5
|
-
import { r as rpc } from './rpc.
|
|
6
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
5
|
+
import { r as rpc } from './rpc.Bf456uf4.js';
|
|
6
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.jLbIuaww.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.C8RiOc4B.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
@@ -58,9 +58,9 @@ async function resolveTestRunner(config, executor) {
|
|
|
58
58
|
]);
|
|
59
59
|
testRunner.config.diffOptions = diffOptions;
|
|
60
60
|
const originalOnTaskUpdate = testRunner.onTaskUpdate;
|
|
61
|
-
testRunner.onTaskUpdate = async (task) => {
|
|
62
|
-
const p = rpc().onTaskUpdate(task);
|
|
63
|
-
await originalOnTaskUpdate?.call(testRunner, task);
|
|
61
|
+
testRunner.onTaskUpdate = async (task, events) => {
|
|
62
|
+
const p = rpc().onTaskUpdate(task, events);
|
|
63
|
+
await originalOnTaskUpdate?.call(testRunner, task, events);
|
|
64
64
|
return p;
|
|
65
65
|
};
|
|
66
66
|
const originalOnCollectStart = testRunner.onCollectStart;
|
|
@@ -14,6 +14,7 @@ const AGENTS = [
|
|
|
14
14
|
"deno"
|
|
15
15
|
];
|
|
16
16
|
const LOCKS = {
|
|
17
|
+
"bun.lock": "bun",
|
|
17
18
|
"bun.lockb": "bun",
|
|
18
19
|
"deno.lock": "deno",
|
|
19
20
|
"pnpm-lock.yaml": "pnpm",
|
|
@@ -94,7 +95,7 @@ async function detectPackageManager(cwd = process.cwd()) {
|
|
|
94
95
|
cwd,
|
|
95
96
|
onUnknown(packageManager) {
|
|
96
97
|
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
|
97
|
-
return
|
|
98
|
+
return undefined;
|
|
98
99
|
}
|
|
99
100
|
});
|
|
100
101
|
return result?.agent || null;
|