vitest 0.0.67 → 0.0.71
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/bin/vitest.mjs +3 -3
- package/dist/cli.js +2451 -0
- package/dist/constants-d4c70610.js +25 -0
- package/dist/entry.js +3755 -0
- package/dist/error-fb6ff2e6.js +1415 -0
- package/dist/global-e40b54d6.js +16 -0
- package/dist/index-6427e0f2.js +12 -0
- package/dist/index-e37648e9.js +31 -0
- package/dist/index.d.ts +412 -5
- package/dist/index.js +5 -46
- package/dist/{chunk-ANPMHBIF.js → suite-819c135e.js} +16 -45
- package/dist/{chunk-5TNYWP3O.js → utils-9dcc4050.js} +1 -18
- package/dist/{runtime/worker.js → worker.js} +31 -50
- package/global.d.ts +0 -1
- package/package.json +14 -8
- package/dist/chunk-APGELTDH.js +0 -19
- package/dist/chunk-R2SMNEBL.js +0 -95
- package/dist/chunk-VLGIKNLC.js +0 -78
- package/dist/chunk-XUIDSY4V.js +0 -35
- package/dist/chunk-YPKHVZRP.js +0 -86
- package/dist/global-PRFYLY7P.js +0 -22
- package/dist/node/cli.d.ts +0 -1
- package/dist/node/cli.js +0 -2612
- package/dist/options-63a726fa.d.ts +0 -294
- package/dist/runtime/entry.d.ts +0 -7
- package/dist/runtime/entry.js +0 -2545
- package/dist/runtime/worker.d.ts +0 -23
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { g as globalApis } from './constants-d4c70610.js';
|
|
2
|
+
import { i as index } from './index-e37648e9.js';
|
|
3
|
+
import 'path';
|
|
4
|
+
import 'url';
|
|
5
|
+
import './suite-819c135e.js';
|
|
6
|
+
import './index-6427e0f2.js';
|
|
7
|
+
import 'chai';
|
|
8
|
+
import 'sinon';
|
|
9
|
+
|
|
10
|
+
function registerApiGlobally() {
|
|
11
|
+
globalApis.forEach((api) => {
|
|
12
|
+
globalThis[api] = index[api];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { registerApiGlobally };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
let urlAlphabet =
|
|
2
|
+
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
3
|
+
let nanoid = (size = 21) => {
|
|
4
|
+
let id = '';
|
|
5
|
+
let i = size;
|
|
6
|
+
while (i--) {
|
|
7
|
+
id += urlAlphabet[(Math.random() * 64) | 0];
|
|
8
|
+
}
|
|
9
|
+
return id
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { nanoid as n };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { s as suite, d as defaultSuite, c as createSuiteHooks, t as test, a as describe, i as it, b as beforeAll, e as afterAll, f as beforeEach, g as afterEach, h as clearContext } from './suite-819c135e.js';
|
|
2
|
+
import chai, { assert, should, expect } from 'chai';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
|
|
5
|
+
const { mock, spy, stub } = sinon;
|
|
6
|
+
sinon.fn = sinon.spy;
|
|
7
|
+
|
|
8
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
9
|
+
__proto__: null,
|
|
10
|
+
suite: suite,
|
|
11
|
+
defaultSuite: defaultSuite,
|
|
12
|
+
createSuiteHooks: createSuiteHooks,
|
|
13
|
+
test: test,
|
|
14
|
+
describe: describe,
|
|
15
|
+
it: it,
|
|
16
|
+
beforeAll: beforeAll,
|
|
17
|
+
afterAll: afterAll,
|
|
18
|
+
beforeEach: beforeEach,
|
|
19
|
+
afterEach: afterEach,
|
|
20
|
+
clearContext: clearContext,
|
|
21
|
+
assert: assert,
|
|
22
|
+
should: should,
|
|
23
|
+
expect: expect,
|
|
24
|
+
chai: chai,
|
|
25
|
+
sinon: sinon,
|
|
26
|
+
mock: mock,
|
|
27
|
+
spy: spy,
|
|
28
|
+
stub: stub
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export { stub as a, index as i, mock as m, spy as s };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,404 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Formatter } from 'picocolors/types';
|
|
2
|
+
import { TransformResult, ViteDevServer } from 'vite';
|
|
3
|
+
import { OptionsReceived } from 'pretty-format';
|
|
3
4
|
import { MessagePort } from 'worker_threads';
|
|
4
|
-
import { TransformResult } from 'vite';
|
|
5
5
|
export { assert, default as chai, expect, should } from 'chai';
|
|
6
6
|
import sinon from 'sinon';
|
|
7
7
|
export { default as sinon } from 'sinon';
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
declare const EXPECTED_COLOR: Formatter;
|
|
10
|
+
declare const RECEIVED_COLOR: Formatter;
|
|
11
|
+
declare const INVERTED_COLOR: Formatter;
|
|
12
|
+
declare const BOLD_WEIGHT: Formatter;
|
|
13
|
+
declare const DIM_COLOR: Formatter;
|
|
14
|
+
declare type MatcherHintOptions = {
|
|
15
|
+
comment?: string;
|
|
16
|
+
expectedColor?: Formatter;
|
|
17
|
+
isDirectExpectCall?: boolean;
|
|
18
|
+
isNot?: boolean;
|
|
19
|
+
promise?: string;
|
|
20
|
+
receivedColor?: Formatter;
|
|
21
|
+
secondArgument?: string;
|
|
22
|
+
secondArgumentColor?: Formatter;
|
|
23
|
+
};
|
|
24
|
+
declare function matcherHint(matcherName: string, received?: string, expected?: string, options?: MatcherHintOptions): string;
|
|
25
|
+
declare const stringify: (object: unknown, maxDepth?: number) => string;
|
|
26
|
+
declare const printReceived: (object: unknown) => string;
|
|
27
|
+
declare const printExpected: (value: unknown) => string;
|
|
28
|
+
declare type DiffOptions = {
|
|
29
|
+
aAnnotation?: string;
|
|
30
|
+
aColor?: Formatter;
|
|
31
|
+
aIndicator?: string;
|
|
32
|
+
bAnnotation?: string;
|
|
33
|
+
bColor?: Formatter;
|
|
34
|
+
bIndicator?: string;
|
|
35
|
+
changeColor?: Formatter;
|
|
36
|
+
changeLineTrailingSpaceColor?: Formatter;
|
|
37
|
+
commonColor?: Formatter;
|
|
38
|
+
commonIndicator?: string;
|
|
39
|
+
commonLineTrailingSpaceColor?: Formatter;
|
|
40
|
+
contextLines?: number;
|
|
41
|
+
emptyFirstOrLastLinePlaceholder?: string;
|
|
42
|
+
expand?: boolean;
|
|
43
|
+
includeChangeCounts?: boolean;
|
|
44
|
+
omitAnnotationLines?: boolean;
|
|
45
|
+
patchColor?: Formatter;
|
|
46
|
+
compareKeys?: any;
|
|
47
|
+
};
|
|
48
|
+
declare function diff(a: any, b: any, options?: DiffOptions): string;
|
|
49
|
+
|
|
50
|
+
declare const jestMatcherUtils_EXPECTED_COLOR: typeof EXPECTED_COLOR;
|
|
51
|
+
declare const jestMatcherUtils_RECEIVED_COLOR: typeof RECEIVED_COLOR;
|
|
52
|
+
declare const jestMatcherUtils_INVERTED_COLOR: typeof INVERTED_COLOR;
|
|
53
|
+
declare const jestMatcherUtils_BOLD_WEIGHT: typeof BOLD_WEIGHT;
|
|
54
|
+
declare const jestMatcherUtils_DIM_COLOR: typeof DIM_COLOR;
|
|
55
|
+
type jestMatcherUtils_MatcherHintOptions = MatcherHintOptions;
|
|
56
|
+
declare const jestMatcherUtils_matcherHint: typeof matcherHint;
|
|
57
|
+
declare const jestMatcherUtils_stringify: typeof stringify;
|
|
58
|
+
declare const jestMatcherUtils_printReceived: typeof printReceived;
|
|
59
|
+
declare const jestMatcherUtils_printExpected: typeof printExpected;
|
|
60
|
+
type jestMatcherUtils_DiffOptions = DiffOptions;
|
|
61
|
+
declare const jestMatcherUtils_diff: typeof diff;
|
|
62
|
+
declare namespace jestMatcherUtils {
|
|
63
|
+
export {
|
|
64
|
+
jestMatcherUtils_EXPECTED_COLOR as EXPECTED_COLOR,
|
|
65
|
+
jestMatcherUtils_RECEIVED_COLOR as RECEIVED_COLOR,
|
|
66
|
+
jestMatcherUtils_INVERTED_COLOR as INVERTED_COLOR,
|
|
67
|
+
jestMatcherUtils_BOLD_WEIGHT as BOLD_WEIGHT,
|
|
68
|
+
jestMatcherUtils_DIM_COLOR as DIM_COLOR,
|
|
69
|
+
jestMatcherUtils_MatcherHintOptions as MatcherHintOptions,
|
|
70
|
+
jestMatcherUtils_matcherHint as matcherHint,
|
|
71
|
+
jestMatcherUtils_stringify as stringify,
|
|
72
|
+
jestMatcherUtils_printReceived as printReceived,
|
|
73
|
+
jestMatcherUtils_printExpected as printExpected,
|
|
74
|
+
jestMatcherUtils_DiffOptions as DiffOptions,
|
|
75
|
+
jestMatcherUtils_diff as diff,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare type Tester = (a: any, b: any) => boolean | undefined;
|
|
80
|
+
declare type MatcherState = {
|
|
81
|
+
assertionCalls: number;
|
|
82
|
+
currentTestName?: string;
|
|
83
|
+
dontThrow?: () => void;
|
|
84
|
+
error?: Error;
|
|
85
|
+
equals: (a: unknown, b: unknown, customTesters?: Array<Tester>, strictCheck?: boolean) => boolean;
|
|
86
|
+
expand?: boolean;
|
|
87
|
+
expectedAssertionsNumber?: number | null;
|
|
88
|
+
expectedAssertionsNumberError?: Error;
|
|
89
|
+
isExpectingAssertions?: boolean;
|
|
90
|
+
isExpectingAssertionsError?: Error;
|
|
91
|
+
isNot: boolean;
|
|
92
|
+
promise: string;
|
|
93
|
+
suppressedErrors: Array<Error>;
|
|
94
|
+
testPath?: string;
|
|
95
|
+
utils: typeof jestMatcherUtils & {
|
|
96
|
+
iterableEquality: Tester;
|
|
97
|
+
subsetEquality: Tester;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
declare type SyncExpectationResult = {
|
|
101
|
+
pass: boolean;
|
|
102
|
+
message: () => string;
|
|
103
|
+
};
|
|
104
|
+
declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
|
|
105
|
+
declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
|
|
106
|
+
declare type RawMatcherFn<T extends MatcherState = MatcherState> = {
|
|
107
|
+
(this: T, received: any, expected: any, options?: any): ExpectationResult;
|
|
108
|
+
};
|
|
109
|
+
declare type MatchersObject<T extends MatcherState = MatcherState> = {
|
|
110
|
+
[id: string]: RawMatcherFn<T>;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
declare class StateManager {
|
|
114
|
+
filesMap: Record<string, File>;
|
|
115
|
+
idMap: Record<string, Task>;
|
|
116
|
+
taskFileMap: WeakMap<Task, File>;
|
|
117
|
+
getFiles(keys?: string[]): File[];
|
|
118
|
+
collectFiles(files: File[]): void;
|
|
119
|
+
updateId(task: Task): void;
|
|
120
|
+
updateTasks(packs: TaskResultPack[]): void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare class SnapshotManager {
|
|
124
|
+
config: ResolvedConfig;
|
|
125
|
+
summary: SnapshotSummary;
|
|
126
|
+
constructor(config: ResolvedConfig);
|
|
127
|
+
clear(): void;
|
|
128
|
+
add(result: SnapshotResult): void;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
132
|
+
declare type Nullable<T> = T | null | undefined;
|
|
133
|
+
declare type Arrayable<T> = T | Array<T>;
|
|
134
|
+
interface ModuleCache {
|
|
135
|
+
promise?: Promise<any>;
|
|
136
|
+
exports?: any;
|
|
137
|
+
transformResult?: TransformResult;
|
|
138
|
+
}
|
|
139
|
+
interface EnvironmentReturn {
|
|
140
|
+
teardown: (global: any) => Awaitable<void>;
|
|
141
|
+
}
|
|
142
|
+
interface Environment {
|
|
143
|
+
name: string;
|
|
144
|
+
setup(global: any): Awaitable<EnvironmentReturn>;
|
|
145
|
+
}
|
|
146
|
+
interface VitestContext {
|
|
147
|
+
config: ResolvedConfig;
|
|
148
|
+
server: ViteDevServer;
|
|
149
|
+
state: StateManager;
|
|
150
|
+
snapshot: SnapshotManager;
|
|
151
|
+
reporter: Reporter;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
155
|
+
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
156
|
+
declare type ComputeMode = 'serial' | 'concurrent';
|
|
157
|
+
interface TaskBase {
|
|
158
|
+
id: string;
|
|
159
|
+
name: string;
|
|
160
|
+
mode: RunMode;
|
|
161
|
+
computeMode: ComputeMode;
|
|
162
|
+
suite?: Suite;
|
|
163
|
+
file?: File;
|
|
164
|
+
result?: TaskResult;
|
|
165
|
+
}
|
|
166
|
+
interface TaskResult {
|
|
167
|
+
state: TaskState;
|
|
168
|
+
start: number;
|
|
169
|
+
end?: number;
|
|
170
|
+
error?: unknown;
|
|
171
|
+
}
|
|
172
|
+
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
173
|
+
interface Suite extends TaskBase {
|
|
174
|
+
type: 'suite';
|
|
175
|
+
tasks: Task[];
|
|
176
|
+
}
|
|
177
|
+
interface File extends Suite {
|
|
178
|
+
filepath: string;
|
|
179
|
+
}
|
|
180
|
+
interface Test extends TaskBase {
|
|
181
|
+
type: 'test';
|
|
182
|
+
suite: Suite;
|
|
183
|
+
result?: TaskResult;
|
|
184
|
+
}
|
|
185
|
+
declare type Task = Test | Suite | File;
|
|
186
|
+
declare type TestFunction = () => Awaitable<void>;
|
|
187
|
+
declare type TestCollectorFn = (name: string, fn: TestFunction, timeout?: number) => void;
|
|
188
|
+
interface ConcurrentCollector {
|
|
189
|
+
(name: string, fn: TestFunction, timeout?: number): void;
|
|
190
|
+
only: TestCollectorFn;
|
|
191
|
+
skip: TestCollectorFn;
|
|
192
|
+
todo: (name: string) => void;
|
|
193
|
+
}
|
|
194
|
+
interface OnlyCollector {
|
|
195
|
+
(name: string, fn: TestFunction, timeout?: number): void;
|
|
196
|
+
concurrent: TestCollectorFn;
|
|
197
|
+
}
|
|
198
|
+
interface SkipCollector {
|
|
199
|
+
(name: string, fn: TestFunction, timeout?: number): void;
|
|
200
|
+
concurrent: TestCollectorFn;
|
|
201
|
+
}
|
|
202
|
+
interface TodoCollector {
|
|
203
|
+
(name: string): void;
|
|
204
|
+
concurrent: (name: string) => void;
|
|
205
|
+
}
|
|
206
|
+
interface TestCollector {
|
|
207
|
+
(name: string, fn: TestFunction, timeout?: number): void;
|
|
208
|
+
concurrent: ConcurrentCollector;
|
|
209
|
+
only: OnlyCollector;
|
|
210
|
+
skip: SkipCollector;
|
|
211
|
+
todo: TodoCollector;
|
|
212
|
+
}
|
|
213
|
+
declare type HookListener<T extends any[]> = (...args: T) => Awaitable<void>;
|
|
214
|
+
interface SuiteHooks {
|
|
215
|
+
beforeAll: HookListener<[Suite]>[];
|
|
216
|
+
afterAll: HookListener<[Suite]>[];
|
|
217
|
+
beforeEach: HookListener<[Test, Suite]>[];
|
|
218
|
+
afterEach: HookListener<[Test, Suite]>[];
|
|
219
|
+
}
|
|
220
|
+
interface SuiteCollector {
|
|
221
|
+
readonly name: string;
|
|
222
|
+
readonly mode: RunMode;
|
|
223
|
+
type: 'collector';
|
|
224
|
+
test: TestCollector;
|
|
225
|
+
tasks: (Suite | Test | SuiteCollector)[];
|
|
226
|
+
collect: (file?: File) => Promise<Suite>;
|
|
227
|
+
clear: () => void;
|
|
228
|
+
on: <T extends keyof SuiteHooks>(name: T, ...fn: SuiteHooks[T]) => void;
|
|
229
|
+
}
|
|
230
|
+
declare type TestFactory = (test: (name: string, fn: TestFunction) => void) => Awaitable<void>;
|
|
231
|
+
interface GlobalContext {
|
|
232
|
+
tasks: (SuiteCollector | Test)[];
|
|
233
|
+
currentSuite: SuiteCollector | null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface Reporter {
|
|
237
|
+
onStart?: (files?: string[]) => Awaitable<void>;
|
|
238
|
+
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
239
|
+
onTaskUpdate?: (pack: TaskResultPack) => Awaitable<void>;
|
|
240
|
+
onWatcherStart?: () => Awaitable<void>;
|
|
241
|
+
onWatcherRerun?: (files: string[], trigger: string) => Awaitable<void>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare type SnapshotData = Record<string, string>;
|
|
245
|
+
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
246
|
+
declare type SnapshotStateOptions = {
|
|
247
|
+
updateSnapshot: SnapshotUpdateState;
|
|
248
|
+
expand?: boolean;
|
|
249
|
+
snapshotFormat?: OptionsReceived;
|
|
250
|
+
};
|
|
251
|
+
declare type SnapshotMatchOptions = {
|
|
252
|
+
testName: string;
|
|
253
|
+
received: unknown;
|
|
254
|
+
key?: string;
|
|
255
|
+
inlineSnapshot?: string;
|
|
256
|
+
isInline: boolean;
|
|
257
|
+
error?: Error;
|
|
258
|
+
};
|
|
259
|
+
interface SnapshotResult {
|
|
260
|
+
filepath: string;
|
|
261
|
+
added: number;
|
|
262
|
+
fileDeleted: boolean;
|
|
263
|
+
matched: number;
|
|
264
|
+
unchecked: number;
|
|
265
|
+
uncheckedKeys: Array<string>;
|
|
266
|
+
unmatched: number;
|
|
267
|
+
updated: number;
|
|
268
|
+
}
|
|
269
|
+
interface UncheckedSnapshot {
|
|
270
|
+
filePath: string;
|
|
271
|
+
keys: Array<string>;
|
|
272
|
+
}
|
|
273
|
+
interface SnapshotSummary {
|
|
274
|
+
added: number;
|
|
275
|
+
didUpdate: boolean;
|
|
276
|
+
failure: boolean;
|
|
277
|
+
filesAdded: number;
|
|
278
|
+
filesRemoved: number;
|
|
279
|
+
filesRemovedList: Array<string>;
|
|
280
|
+
filesUnmatched: number;
|
|
281
|
+
filesUpdated: number;
|
|
282
|
+
matched: number;
|
|
283
|
+
total: number;
|
|
284
|
+
unchecked: number;
|
|
285
|
+
uncheckedKeysByFile: Array<UncheckedSnapshot>;
|
|
286
|
+
unmatched: number;
|
|
287
|
+
updated: number;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
interface UserOptions {
|
|
291
|
+
/**
|
|
292
|
+
* Include globs for test files
|
|
293
|
+
*
|
|
294
|
+
* @default ['**\/*.test.ts']
|
|
295
|
+
*/
|
|
296
|
+
includes?: string[];
|
|
297
|
+
/**
|
|
298
|
+
* Exclude globs for test files
|
|
299
|
+
* @default ['**\/node_modules\/**']
|
|
300
|
+
*/
|
|
301
|
+
excludes?: string[];
|
|
302
|
+
/**
|
|
303
|
+
* Handling for dependencies inlining or externalizing
|
|
304
|
+
*/
|
|
305
|
+
deps?: {
|
|
306
|
+
/**
|
|
307
|
+
* Externalize means that Vite will bypass the package to native Node.
|
|
308
|
+
*
|
|
309
|
+
* Externaled dependencies will not be applied Vite's transformers and resolvers.
|
|
310
|
+
* And does not support HMR on reload.
|
|
311
|
+
*
|
|
312
|
+
* Typically, packages under `node_modules` are externalized.
|
|
313
|
+
*/
|
|
314
|
+
external?: (string | RegExp)[];
|
|
315
|
+
/**
|
|
316
|
+
* Vite will process inlined modules.
|
|
317
|
+
*
|
|
318
|
+
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
319
|
+
*/
|
|
320
|
+
inline?: (string | RegExp)[];
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Register apis globally
|
|
324
|
+
*
|
|
325
|
+
* @default false
|
|
326
|
+
*/
|
|
327
|
+
global?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Running environment
|
|
330
|
+
*
|
|
331
|
+
* Supports 'node', 'jsdom', 'happy-dom'
|
|
332
|
+
*
|
|
333
|
+
* @default 'node'
|
|
334
|
+
*/
|
|
335
|
+
environment?: 'node' | 'jsdom' | 'happy-dom';
|
|
336
|
+
/**
|
|
337
|
+
* Update snapshot files
|
|
338
|
+
*
|
|
339
|
+
* @default false
|
|
340
|
+
*/
|
|
341
|
+
update?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Watch mode
|
|
344
|
+
*
|
|
345
|
+
* @default false
|
|
346
|
+
*/
|
|
347
|
+
watch?: boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Project root
|
|
350
|
+
*/
|
|
351
|
+
root?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Custom reporter for output
|
|
354
|
+
*/
|
|
355
|
+
reporter?: Reporter;
|
|
356
|
+
/**
|
|
357
|
+
* Enable multi-threading
|
|
358
|
+
*
|
|
359
|
+
* @default true
|
|
360
|
+
*/
|
|
361
|
+
threads?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Maximum number of threads
|
|
364
|
+
*
|
|
365
|
+
* @default available CPUs
|
|
366
|
+
*/
|
|
367
|
+
maxThreads?: number;
|
|
368
|
+
/**
|
|
369
|
+
* Minimum number of threads
|
|
370
|
+
*
|
|
371
|
+
* @default available CPUs
|
|
372
|
+
*/
|
|
373
|
+
minThreads?: number;
|
|
374
|
+
interpretDefault?: boolean;
|
|
375
|
+
testTimeout?: number;
|
|
376
|
+
hookTimeout?: number;
|
|
377
|
+
}
|
|
378
|
+
interface CliOptions extends UserOptions {
|
|
379
|
+
/**
|
|
380
|
+
* Filters by name
|
|
381
|
+
*/
|
|
382
|
+
cliFilters?: string[];
|
|
383
|
+
/**
|
|
384
|
+
* Path to the config file.
|
|
385
|
+
*
|
|
386
|
+
* Default resolving to one of:
|
|
387
|
+
* - `vitest.config.js`
|
|
388
|
+
* - `vitest.config.ts`
|
|
389
|
+
* - `vite.config.js`
|
|
390
|
+
* - `vite.config.ts`
|
|
391
|
+
*/
|
|
392
|
+
config?: string | undefined;
|
|
393
|
+
dom?: boolean;
|
|
394
|
+
}
|
|
395
|
+
interface ResolvedConfig extends Omit<Required<CliOptions>, 'config' | 'filters'> {
|
|
396
|
+
config?: string;
|
|
397
|
+
filters?: string[];
|
|
398
|
+
depsInline: (string | RegExp)[];
|
|
399
|
+
depsExternal: (string | RegExp)[];
|
|
400
|
+
snapshotOptions: SnapshotStateOptions;
|
|
401
|
+
}
|
|
9
402
|
|
|
10
403
|
interface WorkerContext {
|
|
11
404
|
port: MessagePort;
|
|
@@ -127,6 +520,17 @@ declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undef
|
|
|
127
520
|
declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
|
|
128
521
|
declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
|
|
129
522
|
declare function clearContext(): void;
|
|
523
|
+
declare global {
|
|
524
|
+
namespace NodeJS {
|
|
525
|
+
interface Process {
|
|
526
|
+
__vitest_worker__: {
|
|
527
|
+
config: ResolvedConfig;
|
|
528
|
+
rpc: RpcCall;
|
|
529
|
+
send: RpcSend;
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
130
534
|
|
|
131
535
|
declare const mock: sinon.SinonMockStatic;
|
|
132
536
|
declare const spy: sinon.SinonSpyStatic;
|
|
@@ -142,6 +546,9 @@ declare module 'vite' {
|
|
|
142
546
|
}
|
|
143
547
|
declare global {
|
|
144
548
|
namespace Chai {
|
|
549
|
+
interface ExpectStatic {
|
|
550
|
+
extend(expects: MatchersObject): void;
|
|
551
|
+
}
|
|
145
552
|
interface Assertion {
|
|
146
553
|
toMatchSnapshot(message?: string): Assertion;
|
|
147
554
|
matchSnapshot(message?: string): Assertion;
|
|
@@ -192,4 +599,4 @@ declare global {
|
|
|
192
599
|
}
|
|
193
600
|
}
|
|
194
601
|
|
|
195
|
-
export { RpcCall, RpcMap, RpcPayload, RpcSend, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, clearContext, createSuiteHooks, defaultSuite, describe, it, mock, spy, stub, suite, test };
|
|
602
|
+
export { Arrayable, Awaitable, CliOptions, ComputeMode, Environment, EnvironmentReturn, File, GlobalContext, HookListener, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserOptions, VitestContext, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, clearContext, createSuiteHooks, defaultSuite, describe, it, mock, spy, stub, suite, test };
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
should,
|
|
7
|
-
sinon,
|
|
8
|
-
spy,
|
|
9
|
-
stub
|
|
10
|
-
} from "./chunk-YPKHVZRP.js";
|
|
11
|
-
import {
|
|
12
|
-
afterAll,
|
|
13
|
-
afterEach,
|
|
14
|
-
beforeAll,
|
|
15
|
-
beforeEach,
|
|
16
|
-
clearContext,
|
|
17
|
-
createSuiteHooks,
|
|
18
|
-
defaultSuite,
|
|
19
|
-
describe,
|
|
20
|
-
it,
|
|
21
|
-
suite,
|
|
22
|
-
test
|
|
23
|
-
} from "./chunk-ANPMHBIF.js";
|
|
24
|
-
import "./chunk-APGELTDH.js";
|
|
25
|
-
import "./chunk-R2SMNEBL.js";
|
|
26
|
-
export {
|
|
27
|
-
afterAll,
|
|
28
|
-
afterEach,
|
|
29
|
-
assert,
|
|
30
|
-
beforeAll,
|
|
31
|
-
beforeEach,
|
|
32
|
-
chai,
|
|
33
|
-
clearContext,
|
|
34
|
-
createSuiteHooks,
|
|
35
|
-
defaultSuite,
|
|
36
|
-
describe,
|
|
37
|
-
expect,
|
|
38
|
-
it,
|
|
39
|
-
mock,
|
|
40
|
-
should,
|
|
41
|
-
sinon,
|
|
42
|
-
spy,
|
|
43
|
-
stub,
|
|
44
|
-
suite,
|
|
45
|
-
test
|
|
46
|
-
};
|
|
1
|
+
export { e as afterAll, g as afterEach, b as beforeAll, f as beforeEach, h as clearContext, c as createSuiteHooks, d as defaultSuite, a as describe, i as it, s as suite, t as test } from './suite-819c135e.js';
|
|
2
|
+
export { assert, default as chai, expect, should } from 'chai';
|
|
3
|
+
export { m as mock, s as spy, a as stub } from './index-e37648e9.js';
|
|
4
|
+
export { default as sinon } from 'sinon';
|
|
5
|
+
import './index-6427e0f2.js';
|
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
nanoid
|
|
3
|
-
} from "./chunk-APGELTDH.js";
|
|
4
|
-
import {
|
|
5
|
-
init_esm_shims
|
|
6
|
-
} from "./chunk-R2SMNEBL.js";
|
|
1
|
+
import { n as nanoid } from './index-6427e0f2.js';
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
init_esm_shims();
|
|
10
|
-
|
|
11
|
-
// src/runtime/context.ts
|
|
12
|
-
init_esm_shims();
|
|
13
|
-
var context = {
|
|
3
|
+
const context = {
|
|
14
4
|
tasks: [],
|
|
15
5
|
currentSuite: null
|
|
16
6
|
};
|
|
17
7
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var fnMap = new WeakMap();
|
|
21
|
-
var hooksMap = new WeakMap();
|
|
8
|
+
const fnMap = new WeakMap();
|
|
9
|
+
const hooksMap = new WeakMap();
|
|
22
10
|
function setFn(key, fn) {
|
|
23
11
|
fnMap.set(key, fn);
|
|
24
12
|
}
|
|
@@ -32,17 +20,16 @@ function getHooks(key) {
|
|
|
32
20
|
return hooksMap.get(key);
|
|
33
21
|
}
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var defaultSuite = suite("");
|
|
23
|
+
const suite = createSuite();
|
|
24
|
+
const defaultSuite = suite("");
|
|
38
25
|
function getCurrentSuite() {
|
|
39
26
|
return context.currentSuite || defaultSuite;
|
|
40
27
|
}
|
|
41
|
-
|
|
28
|
+
const getDefaultTestTimeout = () => {
|
|
42
29
|
var _a, _b;
|
|
43
30
|
return ((_b = (_a = process.__vitest_worker__) == null ? void 0 : _a.config) == null ? void 0 : _b.testTimeout) ?? 5e3;
|
|
44
31
|
};
|
|
45
|
-
|
|
32
|
+
const getDefaultHookTimeout = () => {
|
|
46
33
|
var _a, _b;
|
|
47
34
|
return ((_b = (_a = process.__vitest_worker__) == null ? void 0 : _a.config) == null ? void 0 : _b.hookTimeout) ?? 5e3;
|
|
48
35
|
};
|
|
@@ -152,7 +139,7 @@ function createTestCollector(collectTest) {
|
|
|
152
139
|
todo.concurrent = todo;
|
|
153
140
|
return test2;
|
|
154
141
|
}
|
|
155
|
-
|
|
142
|
+
const test = function() {
|
|
156
143
|
function test2(name, fn, timeout) {
|
|
157
144
|
return getCurrentSuite().test(name, fn, timeout);
|
|
158
145
|
}
|
|
@@ -208,12 +195,12 @@ function createSuite() {
|
|
|
208
195
|
suite2.todo = todo;
|
|
209
196
|
return suite2;
|
|
210
197
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
198
|
+
const describe = suite;
|
|
199
|
+
const it = test;
|
|
200
|
+
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
201
|
+
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
202
|
+
const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
203
|
+
const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
217
204
|
function clearContext() {
|
|
218
205
|
context.tasks.length = 0;
|
|
219
206
|
defaultSuite.clear();
|
|
@@ -234,20 +221,4 @@ function withTimeout(fn, _timeout) {
|
|
|
234
221
|
};
|
|
235
222
|
}
|
|
236
223
|
|
|
237
|
-
export {
|
|
238
|
-
context,
|
|
239
|
-
getFn,
|
|
240
|
-
setHooks,
|
|
241
|
-
getHooks,
|
|
242
|
-
suite,
|
|
243
|
-
defaultSuite,
|
|
244
|
-
createSuiteHooks,
|
|
245
|
-
test,
|
|
246
|
-
describe,
|
|
247
|
-
it,
|
|
248
|
-
beforeAll,
|
|
249
|
-
afterAll,
|
|
250
|
-
beforeEach,
|
|
251
|
-
afterEach,
|
|
252
|
-
clearContext
|
|
253
|
-
};
|
|
224
|
+
export { describe as a, beforeAll as b, createSuiteHooks as c, defaultSuite as d, afterAll as e, beforeEach as f, afterEach as g, clearContext as h, it as i, setHooks as j, context as k, getHooks as l, getFn as m, suite as s, test as t };
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_esm_shims
|
|
3
|
-
} from "./chunk-R2SMNEBL.js";
|
|
4
|
-
|
|
5
|
-
// src/utils.ts
|
|
6
|
-
init_esm_shims();
|
|
7
1
|
function toArray(array) {
|
|
8
2
|
array = array || [];
|
|
9
3
|
if (Array.isArray(array))
|
|
@@ -67,15 +61,4 @@ function getNames(task) {
|
|
|
67
61
|
return names;
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
export {
|
|
71
|
-
toArray,
|
|
72
|
-
notNullish,
|
|
73
|
-
slash,
|
|
74
|
-
partitionSuiteChildren,
|
|
75
|
-
interpretOnlyMode,
|
|
76
|
-
getTests,
|
|
77
|
-
getSuites,
|
|
78
|
-
hasTests,
|
|
79
|
-
hasFailed,
|
|
80
|
-
getNames
|
|
81
|
-
};
|
|
64
|
+
export { getTests as a, getSuites as b, hasTests as c, getNames as g, hasFailed as h, interpretOnlyMode as i, notNullish as n, partitionSuiteChildren as p, slash as s, toArray as t };
|