vitest 0.0.100 → 0.0.104
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/LICENSE.md +44 -168
- package/dist/cli.js +10 -10
- package/dist/{constants-3cbd9066.js → constants-c4dc2ff5.js} +2 -2
- package/dist/entry.js +31 -5
- package/dist/{error-34c1d9e5.js → error-796962c6.js} +7 -8
- package/dist/{global-b84f9970.js → global-166f6789.js} +6 -6
- package/dist/index-145f6f09.js +31 -0
- package/dist/{index-113b8b23.js → index-40564dba.js} +1186 -55
- package/dist/index.d.ts +70 -10
- package/dist/index.js +4 -4
- package/dist/{middleware-991dfa87.js → middleware-0627688d.js} +4 -2
- package/dist/node.d.ts +328 -0
- package/dist/node.js +6 -4
- package/dist/suite-8d666d5a.js +201 -0
- package/dist/{utils-b780070b.js → utils-49e5008c.js} +340 -2
- package/dist/utils.js +3 -1
- package/dist/worker.js +113 -6
- package/node.d.ts +1 -0
- package/package.json +6 -4
- package/dist/index-0b2be7f7.js +0 -11164
- package/dist/index-d57cd3f0.js +0 -351
package/dist/index.d.ts
CHANGED
|
@@ -150,6 +150,12 @@ declare class Any extends AsymmetricMatcher<any> {
|
|
|
150
150
|
getExpectedType(): string;
|
|
151
151
|
toAsymmetricMatcher(): string;
|
|
152
152
|
}
|
|
153
|
+
declare class StringMatching extends AsymmetricMatcher<RegExp> {
|
|
154
|
+
constructor(sample: string | RegExp, inverse?: boolean);
|
|
155
|
+
asymmetricMatch(other: string): boolean;
|
|
156
|
+
toString(): string;
|
|
157
|
+
getExpectedType(): string;
|
|
158
|
+
}
|
|
153
159
|
|
|
154
160
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
155
161
|
declare type Nullable<T> = T | null | undefined;
|
|
@@ -303,12 +309,12 @@ interface InlineConfig {
|
|
|
303
309
|
/**
|
|
304
310
|
* Include globs for test files
|
|
305
311
|
*
|
|
306
|
-
* @default ['**\/*.test.ts']
|
|
312
|
+
* @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
307
313
|
*/
|
|
308
314
|
include?: string[];
|
|
309
315
|
/**
|
|
310
316
|
* Exclude globs for test files
|
|
311
|
-
* @default ['
|
|
317
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
312
318
|
*/
|
|
313
319
|
exclude?: string[];
|
|
314
320
|
/**
|
|
@@ -426,6 +432,21 @@ interface InlineConfig {
|
|
|
426
432
|
* @default false
|
|
427
433
|
*/
|
|
428
434
|
api?: boolean | number;
|
|
435
|
+
/**
|
|
436
|
+
* Will call `.mockClear()` on all spies before each test
|
|
437
|
+
* @default false
|
|
438
|
+
*/
|
|
439
|
+
clearMocks?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Will call `.mockReset()` on all spies before each test
|
|
442
|
+
* @default false
|
|
443
|
+
*/
|
|
444
|
+
mockReset?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Will call `.mockRestore()` on all spies before each test
|
|
447
|
+
* @default false
|
|
448
|
+
*/
|
|
449
|
+
restoreMocks?: boolean;
|
|
429
450
|
}
|
|
430
451
|
interface UserConfig extends InlineConfig {
|
|
431
452
|
/**
|
|
@@ -446,6 +467,10 @@ interface UserConfig extends InlineConfig {
|
|
|
446
467
|
* Do not watch
|
|
447
468
|
*/
|
|
448
469
|
run?: boolean;
|
|
470
|
+
/**
|
|
471
|
+
* Pass with no tests
|
|
472
|
+
*/
|
|
473
|
+
passWithNoTests?: boolean;
|
|
449
474
|
}
|
|
450
475
|
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'> {
|
|
451
476
|
config?: string;
|
|
@@ -490,6 +515,7 @@ declare global {
|
|
|
490
515
|
rpc: RpcCall;
|
|
491
516
|
send: RpcSend;
|
|
492
517
|
current?: Test;
|
|
518
|
+
filepath?: string;
|
|
493
519
|
moduleCache: Map<string, ModuleCache>;
|
|
494
520
|
};
|
|
495
521
|
}
|
|
@@ -541,6 +567,37 @@ interface JestMockCompat<TArgs extends any[] = any[], TReturns = any> {
|
|
|
541
567
|
interface JestMockCompatFn<TArgs extends any[] = any, TReturns = any> extends JestMockCompat<TArgs, TReturns> {
|
|
542
568
|
(...args: TArgs): TReturns;
|
|
543
569
|
}
|
|
570
|
+
declare type MockableFunction = (...args: Array<any>) => any;
|
|
571
|
+
declare type MethodKeysOf<T> = {
|
|
572
|
+
[K in keyof T]: T[K] extends MockableFunction ? K : never;
|
|
573
|
+
}[keyof T];
|
|
574
|
+
declare type PropertyKeysOf<T> = {
|
|
575
|
+
[K in keyof T]: T[K] extends MockableFunction ? never : K;
|
|
576
|
+
}[keyof T];
|
|
577
|
+
declare type ArgumentsOf<T> = T extends (...args: infer A) => any ? A : never;
|
|
578
|
+
declare type ConstructorArgumentsOf<T> = T extends new (...args: infer A) => any ? A : never;
|
|
579
|
+
declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? JestMockCompatFn<ConstructorArgumentsOf<T>, R> : T;
|
|
580
|
+
declare type MockedFunction<T extends MockableFunction> = MockWithArgs<T> & {
|
|
581
|
+
[K in keyof T]: T[K];
|
|
582
|
+
};
|
|
583
|
+
declare type MockedFunctionDeep<T extends MockableFunction> = MockWithArgs<T> & MockedObjectDeep<T>;
|
|
584
|
+
declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
585
|
+
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunction<T[K]> : T[K];
|
|
586
|
+
} & {
|
|
587
|
+
[K in PropertyKeysOf<T>]: T[K];
|
|
588
|
+
};
|
|
589
|
+
declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
590
|
+
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunctionDeep<T[K]> : T[K];
|
|
591
|
+
} & {
|
|
592
|
+
[K in PropertyKeysOf<T>]: MaybeMockedDeep<T[K]>;
|
|
593
|
+
};
|
|
594
|
+
declare type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
595
|
+
declare type MaybeMocked<T> = T extends MockableFunction ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
596
|
+
interface MockWithArgs<T extends MockableFunction> extends JestMockCompatFn<ArgumentsOf<T>, ReturnType<T>> {
|
|
597
|
+
new (...args: ConstructorArgumentsOf<T>): T;
|
|
598
|
+
(...args: ArgumentsOf<T>): ReturnType<T>;
|
|
599
|
+
}
|
|
600
|
+
declare const spies: Set<JestMockCompat<any[], any>>;
|
|
544
601
|
declare function spyOn<T, K extends keyof T>(obj: T, method: K, accessType?: 'get' | 'set'): T[K] extends (...args: infer TArgs) => infer TReturnValue ? JestMockCompat<TArgs, TReturnValue> : JestMockCompat;
|
|
545
602
|
declare type Awaited<T> = T extends Promise<infer R> ? R : never;
|
|
546
603
|
declare function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TArgs, R>;
|
|
@@ -555,17 +612,19 @@ declare class VitestUtils {
|
|
|
555
612
|
runAllTimers(): void | Promise<void>;
|
|
556
613
|
advanceTimersByTime(ms: number): void | Promise<void>;
|
|
557
614
|
advanceTimersToNextTimer(): void | Promise<void>;
|
|
558
|
-
runAllTicks(): void | Promise<void>;
|
|
559
|
-
setSystemTime(time?: number | Date): void;
|
|
560
|
-
getRealSystemTime(): number;
|
|
561
615
|
getTimerCount(): number;
|
|
562
616
|
spyOn: typeof spyOn;
|
|
563
617
|
fn: typeof fn;
|
|
564
|
-
mock
|
|
618
|
+
mock(path: string): void;
|
|
619
|
+
unmock(path: string): void;
|
|
620
|
+
importActual<T>(path: string): Promise<T>;
|
|
621
|
+
importMock<T>(path: string): Promise<T>;
|
|
622
|
+
mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
623
|
+
mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
565
624
|
isMockFunction(fn: any): any;
|
|
566
|
-
clearAllMocks():
|
|
567
|
-
resetAllMocks():
|
|
568
|
-
restoreAllMocks():
|
|
625
|
+
clearAllMocks(): this;
|
|
626
|
+
resetAllMocks(): this;
|
|
627
|
+
restoreAllMocks(): this;
|
|
569
628
|
}
|
|
570
629
|
declare const vitest: VitestUtils;
|
|
571
630
|
declare const vi: VitestUtils;
|
|
@@ -589,6 +648,7 @@ declare global {
|
|
|
589
648
|
objectContaining(expected: any): ObjectContaining;
|
|
590
649
|
any(constructor: unknown): Any;
|
|
591
650
|
arrayContaining(expected: any): ArrayContaining;
|
|
651
|
+
stringMatching(expected: RegExp): StringMatching;
|
|
592
652
|
}
|
|
593
653
|
interface Assertion {
|
|
594
654
|
chaiEqual(expected: any): void;
|
|
@@ -643,4 +703,4 @@ declare global {
|
|
|
643
703
|
}
|
|
644
704
|
}
|
|
645
705
|
|
|
646
|
-
export { ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, fn, it, spyOn, suite, test, vi, vitest };
|
|
706
|
+
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, ConstructorArgumentsOf, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, PropertyKeysOf, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, fn, it, spies, spyOn, suite, test, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach
|
|
1
|
+
export { d as describe, i as it, s as suite, t as test } from './suite-8d666d5a.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './index-145f6f09.js';
|
|
3
|
+
export { assert, default as chai, expect, should } from 'chai';
|
|
4
|
+
export { f as fn, s as spies, a as spyOn, b as vi, v as vitest } from './utils-49e5008c.js';
|
|
3
5
|
import './index-9e71c815.js';
|
|
4
|
-
import './utils-b780070b.js';
|
|
5
6
|
import 'tty';
|
|
6
7
|
import 'local-pkg';
|
|
7
8
|
import 'path';
|
|
8
|
-
import './_commonjsHelpers-bdec4bbd.js';
|
|
9
9
|
import 'tinyspy';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { A as API_PATH } from './constants-
|
|
1
|
+
import { A as API_PATH } from './constants-c4dc2ff5.js';
|
|
2
2
|
import 'url';
|
|
3
|
-
import './utils-
|
|
3
|
+
import './utils-49e5008c.js';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
7
|
+
import 'chai';
|
|
8
|
+
import 'tinyspy';
|
|
7
9
|
|
|
8
10
|
/*! (c) 2020 Andrea Giammarchi */
|
|
9
11
|
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
|
+
import { OptionsReceived } from 'pretty-format';
|
|
3
|
+
|
|
4
|
+
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
5
|
+
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
6
|
+
interface UserConsoleLog {
|
|
7
|
+
content: string;
|
|
8
|
+
type: 'stdout' | 'stderr';
|
|
9
|
+
taskId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
13
|
+
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
14
|
+
declare type ComputeMode = 'serial' | 'concurrent';
|
|
15
|
+
interface TaskBase {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
mode: RunMode;
|
|
19
|
+
computeMode: ComputeMode;
|
|
20
|
+
suite?: Suite;
|
|
21
|
+
file?: File;
|
|
22
|
+
result?: TaskResult;
|
|
23
|
+
}
|
|
24
|
+
interface TaskResult {
|
|
25
|
+
state: TaskState;
|
|
26
|
+
start: number;
|
|
27
|
+
end?: number;
|
|
28
|
+
error?: unknown;
|
|
29
|
+
}
|
|
30
|
+
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
31
|
+
interface Suite extends TaskBase {
|
|
32
|
+
type: 'suite';
|
|
33
|
+
tasks: Task[];
|
|
34
|
+
}
|
|
35
|
+
interface File extends Suite {
|
|
36
|
+
filepath: string;
|
|
37
|
+
}
|
|
38
|
+
interface Test extends TaskBase {
|
|
39
|
+
type: 'test';
|
|
40
|
+
suite: Suite;
|
|
41
|
+
result?: TaskResult;
|
|
42
|
+
fails?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare type Task = Test | Suite | File;
|
|
45
|
+
|
|
46
|
+
interface Reporter {
|
|
47
|
+
onStart?: (files?: string[]) => Awaitable<void>;
|
|
48
|
+
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
49
|
+
onTaskUpdate?: (pack: TaskResultPack) => Awaitable<void>;
|
|
50
|
+
onWatcherStart?: () => Awaitable<void>;
|
|
51
|
+
onWatcherRerun?: (files: string[], trigger: string) => Awaitable<void>;
|
|
52
|
+
onServerRestart?: () => Awaitable<void>;
|
|
53
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
57
|
+
declare type SnapshotStateOptions = {
|
|
58
|
+
updateSnapshot: SnapshotUpdateState;
|
|
59
|
+
expand?: boolean;
|
|
60
|
+
snapshotFormat?: OptionsReceived;
|
|
61
|
+
};
|
|
62
|
+
interface SnapshotResult {
|
|
63
|
+
filepath: string;
|
|
64
|
+
added: number;
|
|
65
|
+
fileDeleted: boolean;
|
|
66
|
+
matched: number;
|
|
67
|
+
unchecked: number;
|
|
68
|
+
uncheckedKeys: Array<string>;
|
|
69
|
+
unmatched: number;
|
|
70
|
+
updated: number;
|
|
71
|
+
}
|
|
72
|
+
interface UncheckedSnapshot {
|
|
73
|
+
filePath: string;
|
|
74
|
+
keys: Array<string>;
|
|
75
|
+
}
|
|
76
|
+
interface SnapshotSummary {
|
|
77
|
+
added: number;
|
|
78
|
+
didUpdate: boolean;
|
|
79
|
+
failure: boolean;
|
|
80
|
+
filesAdded: number;
|
|
81
|
+
filesRemoved: number;
|
|
82
|
+
filesRemovedList: Array<string>;
|
|
83
|
+
filesUnmatched: number;
|
|
84
|
+
filesUpdated: number;
|
|
85
|
+
matched: number;
|
|
86
|
+
total: number;
|
|
87
|
+
unchecked: number;
|
|
88
|
+
uncheckedKeysByFile: Array<UncheckedSnapshot>;
|
|
89
|
+
unmatched: number;
|
|
90
|
+
updated: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
94
|
+
interface InlineConfig {
|
|
95
|
+
/**
|
|
96
|
+
* Include globs for test files
|
|
97
|
+
*
|
|
98
|
+
* @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
99
|
+
*/
|
|
100
|
+
include?: string[];
|
|
101
|
+
/**
|
|
102
|
+
* Exclude globs for test files
|
|
103
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
104
|
+
*/
|
|
105
|
+
exclude?: string[];
|
|
106
|
+
/**
|
|
107
|
+
* Handling for dependencies inlining or externalizing
|
|
108
|
+
*/
|
|
109
|
+
deps?: {
|
|
110
|
+
/**
|
|
111
|
+
* Externalize means that Vite will bypass the package to native Node.
|
|
112
|
+
*
|
|
113
|
+
* Externalized dependencies will not be applied Vite's transformers and resolvers.
|
|
114
|
+
* And does not support HMR on reload.
|
|
115
|
+
*
|
|
116
|
+
* Typically, packages under `node_modules` are externalized.
|
|
117
|
+
*/
|
|
118
|
+
external?: (string | RegExp)[];
|
|
119
|
+
/**
|
|
120
|
+
* Vite will process inlined modules.
|
|
121
|
+
*
|
|
122
|
+
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
123
|
+
*/
|
|
124
|
+
inline?: (string | RegExp)[];
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Register apis globally
|
|
128
|
+
*
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
global?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Running environment
|
|
134
|
+
*
|
|
135
|
+
* Supports 'node', 'jsdom', 'happy-dom'
|
|
136
|
+
*
|
|
137
|
+
* @default 'node'
|
|
138
|
+
*/
|
|
139
|
+
environment?: BuiltinEnvironment;
|
|
140
|
+
/**
|
|
141
|
+
* Update snapshot files
|
|
142
|
+
*
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
update?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Watch mode
|
|
148
|
+
*
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
watch?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Project root
|
|
154
|
+
*/
|
|
155
|
+
root?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Custom reporter for output
|
|
158
|
+
*/
|
|
159
|
+
reporters?: Reporter | Reporter[];
|
|
160
|
+
/**
|
|
161
|
+
* Enable multi-threading
|
|
162
|
+
*
|
|
163
|
+
* @default true
|
|
164
|
+
*/
|
|
165
|
+
threads?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Maximum number of threads
|
|
168
|
+
*
|
|
169
|
+
* @default available CPUs
|
|
170
|
+
*/
|
|
171
|
+
maxThreads?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Minimum number of threads
|
|
174
|
+
*
|
|
175
|
+
* @default available CPUs
|
|
176
|
+
*/
|
|
177
|
+
minThreads?: number;
|
|
178
|
+
interpretDefault?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Default timeout of a test in milliseconds
|
|
181
|
+
*
|
|
182
|
+
* @default 5000
|
|
183
|
+
*/
|
|
184
|
+
testTimeout?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Default timeout of a hook in milliseconds
|
|
187
|
+
*
|
|
188
|
+
* @default 5000
|
|
189
|
+
*/
|
|
190
|
+
hookTimeout?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Silent mode
|
|
193
|
+
*
|
|
194
|
+
* @default false
|
|
195
|
+
*/
|
|
196
|
+
silent?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Path to setup files
|
|
199
|
+
*/
|
|
200
|
+
setupFiles?: string | string[];
|
|
201
|
+
/**
|
|
202
|
+
* Pattern of file paths to be ignore from triggering watch rerun
|
|
203
|
+
*
|
|
204
|
+
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
205
|
+
*/
|
|
206
|
+
watchIgnore?: (string | RegExp)[];
|
|
207
|
+
/**
|
|
208
|
+
* Open Vitest UI
|
|
209
|
+
* @internal WIP
|
|
210
|
+
*/
|
|
211
|
+
open?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Listen to port and serve API
|
|
214
|
+
*
|
|
215
|
+
* When set to true, the default port is 55555
|
|
216
|
+
*
|
|
217
|
+
* @internal WIP
|
|
218
|
+
* @default false
|
|
219
|
+
*/
|
|
220
|
+
api?: boolean | number;
|
|
221
|
+
/**
|
|
222
|
+
* Will call `.mockClear()` on all spies before each test
|
|
223
|
+
* @default false
|
|
224
|
+
*/
|
|
225
|
+
clearMocks?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Will call `.mockReset()` on all spies before each test
|
|
228
|
+
* @default false
|
|
229
|
+
*/
|
|
230
|
+
mockReset?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Will call `.mockRestore()` on all spies before each test
|
|
233
|
+
* @default false
|
|
234
|
+
*/
|
|
235
|
+
restoreMocks?: boolean;
|
|
236
|
+
}
|
|
237
|
+
interface UserConfig extends InlineConfig {
|
|
238
|
+
/**
|
|
239
|
+
* Path to the config file.
|
|
240
|
+
*
|
|
241
|
+
* Default resolving to one of:
|
|
242
|
+
* - `vitest.config.js`
|
|
243
|
+
* - `vitest.config.ts`
|
|
244
|
+
* - `vite.config.js`
|
|
245
|
+
* - `vite.config.ts`
|
|
246
|
+
*/
|
|
247
|
+
config?: string | undefined;
|
|
248
|
+
/**
|
|
249
|
+
* Use happy-dom
|
|
250
|
+
*/
|
|
251
|
+
dom?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Do not watch
|
|
254
|
+
*/
|
|
255
|
+
run?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Pass with no tests
|
|
258
|
+
*/
|
|
259
|
+
passWithNoTests?: boolean;
|
|
260
|
+
}
|
|
261
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'> {
|
|
262
|
+
config?: string;
|
|
263
|
+
filters?: string[];
|
|
264
|
+
depsInline: (string | RegExp)[];
|
|
265
|
+
depsExternal: (string | RegExp)[];
|
|
266
|
+
snapshotOptions: SnapshotStateOptions;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
declare class SnapshotManager {
|
|
270
|
+
config: ResolvedConfig;
|
|
271
|
+
summary: SnapshotSummary;
|
|
272
|
+
constructor(config: ResolvedConfig);
|
|
273
|
+
clear(): void;
|
|
274
|
+
add(result: SnapshotResult): void;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
278
|
+
interface WorkerPool {
|
|
279
|
+
runTests: RunWithFiles;
|
|
280
|
+
collectTests: RunWithFiles;
|
|
281
|
+
close: () => Promise<void>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare class StateManager {
|
|
285
|
+
filesMap: Record<string, File>;
|
|
286
|
+
idMap: Record<string, Task>;
|
|
287
|
+
taskFileMap: WeakMap<Task, File>;
|
|
288
|
+
getFiles(keys?: string[]): File[];
|
|
289
|
+
collectFiles(files: File[]): void;
|
|
290
|
+
updateId(task: Task): void;
|
|
291
|
+
updateTasks(packs: TaskResultPack[]): void;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
declare class Vitest {
|
|
295
|
+
config: ResolvedConfig;
|
|
296
|
+
server: ViteDevServer;
|
|
297
|
+
state: StateManager;
|
|
298
|
+
snapshot: SnapshotManager;
|
|
299
|
+
reporters: Reporter[];
|
|
300
|
+
console: Console;
|
|
301
|
+
pool: WorkerPool | undefined;
|
|
302
|
+
invalidates: Set<string>;
|
|
303
|
+
changedTests: Set<string>;
|
|
304
|
+
runningPromise?: Promise<void>;
|
|
305
|
+
isFirstRun: boolean;
|
|
306
|
+
restartsCount: number;
|
|
307
|
+
private _onRestartListeners;
|
|
308
|
+
constructor();
|
|
309
|
+
setServer(options: UserConfig, server: ViteDevServer): void;
|
|
310
|
+
start(filters?: string[]): Promise<void>;
|
|
311
|
+
runFiles(files: string[]): Promise<void>;
|
|
312
|
+
log(...args: any[]): void;
|
|
313
|
+
error(...args: any[]): void;
|
|
314
|
+
private _rerunTimer;
|
|
315
|
+
private scheduleRerun;
|
|
316
|
+
private unregisterWatcher;
|
|
317
|
+
private registerWatcher;
|
|
318
|
+
private handleFileChanged;
|
|
319
|
+
close(): Promise<void>;
|
|
320
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
321
|
+
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
322
|
+
isTargetFile(id: string): boolean;
|
|
323
|
+
onServerRestarted(fn: () => void): void;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
declare function createVitest(options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
|
|
327
|
+
|
|
328
|
+
export { Vitest, createVitest };
|
package/dist/node.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import './utils-
|
|
1
|
+
export { c as createVitest } from './index-40564dba.js';
|
|
2
|
+
import './utils-49e5008c.js';
|
|
3
3
|
import 'tty';
|
|
4
4
|
import 'local-pkg';
|
|
5
5
|
import 'path';
|
|
6
|
+
import 'chai';
|
|
7
|
+
import 'tinyspy';
|
|
6
8
|
import 'vite';
|
|
7
9
|
import 'process';
|
|
8
10
|
import 'fs';
|
|
@@ -10,10 +12,10 @@ import 'os';
|
|
|
10
12
|
import 'util';
|
|
11
13
|
import 'stream';
|
|
12
14
|
import 'events';
|
|
13
|
-
import './constants-
|
|
15
|
+
import './constants-c4dc2ff5.js';
|
|
14
16
|
import 'url';
|
|
15
17
|
import 'perf_hooks';
|
|
16
|
-
import './error-
|
|
18
|
+
import './error-796962c6.js';
|
|
17
19
|
import './index-825cb54c.js';
|
|
18
20
|
import './_commonjsHelpers-bdec4bbd.js';
|
|
19
21
|
import 'assert';
|