vitest 3.0.0-beta.4 → 3.0.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/dist/browser.d.ts +2 -2
- package/dist/chunks/{base.BJ8KO-VX.js → base.CUDzyU2J.js} +1 -1
- package/dist/chunks/{cac.BAYqQ2aM.js → cac.DZC9WjGM.js} +6 -6
- package/dist/chunks/{cli-api.Dhl34Trr.js → cli-api.CmJw5Cd_.js} +901 -65
- package/dist/chunks/{creator.Ot9GlSGw.js → creator.DztqrnyH.js} +1 -1
- package/dist/chunks/global.CnI8_G5V.d.ts +133 -0
- package/dist/chunks/{index.B2M9nD1V.js → index.CUcwvygK.js} +4 -4
- package/dist/chunks/{index.DQboAxJm.js → index.D9C26wCk.js} +1 -0
- package/dist/chunks/{index.CAueP3cK.js → index.TKSL1HjN.js} +188 -933
- package/dist/chunks/{reporters.Dcdq51WE.d.ts → reporters.Y8BYiXBN.d.ts} +340 -239
- package/dist/chunks/{resolveConfig.kZFMjKCQ.js → resolveConfig.CSLLD33d.js} +137 -52
- package/dist/chunks/{rpc.C3q9uwRX.js → rpc.TVf73xOu.js} +0 -1
- package/dist/chunks/{runBaseTests.URiUrnWK.js → runBaseTests.C0T_TQwH.js} +2 -2
- package/dist/chunks/{RandomSequencer.DB__To1b.js → typechecker.BJMkWMXo.js} +53 -106
- package/dist/chunks/{utils.yHKcm4dz.js → utils.DJWL04yX.js} +1 -1
- package/dist/chunks/{vite.DzluO1Kj.d.ts → vite.CQ0dHgkN.d.ts} +1 -1
- 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.d.ts +3 -3
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +5 -4
- package/dist/execute.d.ts +1 -1
- package/dist/index.d.ts +17 -118
- package/dist/node.d.ts +11 -8
- package/dist/node.js +25 -23
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -6
- package/dist/runners.d.ts +1 -0
- package/dist/runners.js +7 -7
- package/dist/worker.js +1 -1
- package/dist/workers/forks.js +1 -1
- package/dist/workers/runVmTests.js +2 -2
- package/dist/workers/threads.js +1 -1
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +2 -2
- package/package.json +13 -13
- package/dist/chunks/types.BOjykUpq.d.ts +0 -27
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
4
|
+
import { detectPackageManager, installPackage } from './index.D9C26wCk.js';
|
|
5
5
|
import { p as prompt, f as findUp } from './index.BJDntFik.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
7
|
import c from 'tinyrainbow';
|
|
@@ -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 };
|
|
@@ -2,7 +2,7 @@ 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.
|
|
5
|
+
import { r as rpc } from './rpc.TVf73xOu.js';
|
|
6
6
|
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.D0zLenuv.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.C8RiOc4B.js';
|
|
8
8
|
|
|
@@ -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;
|