vitest 0.0.103 → 0.0.107
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 +73 -0
- package/dist/cli.js +9 -8
- package/dist/{constants-a1417084.js → constants-82dad049.js} +2 -2
- package/dist/entry.js +29 -5
- package/dist/{error-0e2f75a4.js → error-e81aa23d.js} +18 -30
- package/dist/{global-12f52a87.js → global-0f4da031.js} +5 -5
- package/dist/{index-0c3a317d.js → index-1ede1cc5.js} +6 -2
- package/dist/index-77f19d39.js +31 -0
- package/dist/{index-825cb54c.js → index-84978a77.js} +1 -1
- package/dist/{index-6f17b444.js → index-8cc284f9.js} +1142 -22
- package/dist/index.d.ts +68 -8
- package/dist/index.js +3 -3
- package/dist/{middleware-05e03d95.js → middleware-0c8d46aa.js} +4 -2
- package/dist/node.d.ts +15 -0
- package/dist/node.js +7 -6
- package/dist/{suite-64b3e636.js → suite-ff89a82e.js} +1 -1
- package/dist/utils-92ec89d1.js +814 -0
- package/dist/utils.js +3 -1
- package/dist/worker.js +113 -6
- package/package.json +7 -5
- package/vitest.mjs +1 -1
- package/dist/_commonjsHelpers-bdec4bbd.js +0 -7
- package/dist/index-a190f5a1.js +0 -352
- package/dist/utils-c8e62373.js +0 -346
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;
|
|
@@ -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
|
/**
|
|
@@ -494,6 +515,7 @@ declare global {
|
|
|
494
515
|
rpc: RpcCall;
|
|
495
516
|
send: RpcSend;
|
|
496
517
|
current?: Test;
|
|
518
|
+
filepath?: string;
|
|
497
519
|
moduleCache: Map<string, ModuleCache>;
|
|
498
520
|
};
|
|
499
521
|
}
|
|
@@ -545,6 +567,37 @@ interface JestMockCompat<TArgs extends any[] = any[], TReturns = any> {
|
|
|
545
567
|
interface JestMockCompatFn<TArgs extends any[] = any, TReturns = any> extends JestMockCompat<TArgs, TReturns> {
|
|
546
568
|
(...args: TArgs): TReturns;
|
|
547
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>>;
|
|
548
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;
|
|
549
602
|
declare type Awaited<T> = T extends Promise<infer R> ? R : never;
|
|
550
603
|
declare function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TArgs, R>;
|
|
@@ -552,6 +605,7 @@ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...ar
|
|
|
552
605
|
|
|
553
606
|
declare class VitestUtils {
|
|
554
607
|
private _timers;
|
|
608
|
+
private _mockedDate;
|
|
555
609
|
constructor();
|
|
556
610
|
useFakeTimers(): void;
|
|
557
611
|
useRealTimers(): void;
|
|
@@ -559,17 +613,22 @@ declare class VitestUtils {
|
|
|
559
613
|
runAllTimers(): void | Promise<void>;
|
|
560
614
|
advanceTimersByTime(ms: number): void | Promise<void>;
|
|
561
615
|
advanceTimersToNextTimer(): void | Promise<void>;
|
|
562
|
-
runAllTicks(): void | Promise<void>;
|
|
563
|
-
setSystemTime(time?: number | Date): void;
|
|
564
|
-
getRealSystemTime(): number;
|
|
565
616
|
getTimerCount(): number;
|
|
617
|
+
mockCurrentDate(date: string | number | Date): void;
|
|
618
|
+
restoreCurrentDate(): void;
|
|
619
|
+
getMockedDate(): string | number | Date | null;
|
|
566
620
|
spyOn: typeof spyOn;
|
|
567
621
|
fn: typeof fn;
|
|
568
|
-
mock
|
|
622
|
+
mock(path: string): void;
|
|
623
|
+
unmock(path: string): void;
|
|
624
|
+
importActual<T>(path: string): Promise<T>;
|
|
625
|
+
importMock<T>(path: string): Promise<T>;
|
|
626
|
+
mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
627
|
+
mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
569
628
|
isMockFunction(fn: any): any;
|
|
570
|
-
clearAllMocks():
|
|
571
|
-
resetAllMocks():
|
|
572
|
-
restoreAllMocks():
|
|
629
|
+
clearAllMocks(): this;
|
|
630
|
+
resetAllMocks(): this;
|
|
631
|
+
restoreAllMocks(): this;
|
|
573
632
|
}
|
|
574
633
|
declare const vitest: VitestUtils;
|
|
575
634
|
declare const vi: VitestUtils;
|
|
@@ -593,6 +652,7 @@ declare global {
|
|
|
593
652
|
objectContaining(expected: any): ObjectContaining;
|
|
594
653
|
any(constructor: unknown): Any;
|
|
595
654
|
arrayContaining(expected: any): ArrayContaining;
|
|
655
|
+
stringMatching(expected: RegExp): StringMatching;
|
|
596
656
|
}
|
|
597
657
|
interface Assertion {
|
|
598
658
|
chaiEqual(expected: any): void;
|
|
@@ -647,4 +707,4 @@ declare global {
|
|
|
647
707
|
}
|
|
648
708
|
}
|
|
649
709
|
|
|
650
|
-
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 };
|
|
710
|
+
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,8 +1,8 @@
|
|
|
1
|
-
export { d as describe, i as it, s as suite, t as test } from './suite-
|
|
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-ff89a82e.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './index-77f19d39.js';
|
|
3
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-92ec89d1.js';
|
|
4
5
|
import './index-9e71c815.js';
|
|
5
|
-
import './utils-c8e62373.js';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
8
|
import 'path';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { A as API_PATH } from './constants-
|
|
1
|
+
import { A as API_PATH } from './constants-82dad049.js';
|
|
2
2
|
import 'url';
|
|
3
|
-
import './utils-
|
|
3
|
+
import './utils-92ec89d1.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
CHANGED
|
@@ -218,6 +218,21 @@ interface InlineConfig {
|
|
|
218
218
|
* @default false
|
|
219
219
|
*/
|
|
220
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;
|
|
221
236
|
}
|
|
222
237
|
interface UserConfig extends InlineConfig {
|
|
223
238
|
/**
|
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-8cc284f9.js';
|
|
2
|
+
import './utils-92ec89d1.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,12 +12,11 @@ import 'os';
|
|
|
10
12
|
import 'util';
|
|
11
13
|
import 'stream';
|
|
12
14
|
import 'events';
|
|
13
|
-
import './constants-
|
|
15
|
+
import './constants-82dad049.js';
|
|
14
16
|
import 'url';
|
|
15
17
|
import 'perf_hooks';
|
|
16
|
-
import './error-
|
|
17
|
-
import './index-
|
|
18
|
-
import './_commonjsHelpers-bdec4bbd.js';
|
|
18
|
+
import './error-e81aa23d.js';
|
|
19
|
+
import './index-84978a77.js';
|
|
19
20
|
import 'assert';
|
|
20
21
|
import 'worker_threads';
|
|
21
22
|
import 'tinypool';
|