vitest 0.9.2 → 0.10.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/LICENSE.md +7 -0
- package/dist/{chunk-api-setup.7290422e.js → chunk-api-setup.d70fc960.js} +5 -5
- package/dist/{chunk-constants.e59013dc.js → chunk-constants.d540b1d1.js} +1 -1
- package/dist/{chunk-defaults.9aa0ce42.js → chunk-defaults.04d5d90b.js} +1 -1
- package/dist/{chunk-install-pkg.7dd40977.js → chunk-install-pkg.73b84ae1.js} +113 -115
- package/dist/chunk-integrations-globals.d2c09cd2.js +29 -0
- package/dist/chunk-integrations-spy.f036df6f.js +102 -0
- package/dist/{chunk-runtime-chain.94cf66a4.js → chunk-runtime-chain.f863f182.js} +934 -897
- package/dist/{chunk-runtime-mocker.7f4b1850.js → chunk-runtime-mocker.111ac858.js} +3 -3
- package/dist/{chunk-runtime-rpc.4b80b6bd.js → chunk-runtime-rpc.8f648236.js} +1 -1
- package/dist/{chunk-utils-global.10dcdfa6.js → chunk-utils-global.37a7c822.js} +8 -10
- package/dist/{chunk-utils-timers.4800834c.js → chunk-utils-timers.12bc05d1.js} +1404 -1057
- package/dist/{chunk-vite-node-externalize.ddf2a6fb.js → chunk-vite-node-externalize.5c678054.js} +1773 -4417
- package/dist/{chunk-vite-node-utils.7f0053fb.js → chunk-vite-node-utils.33447cc0.js} +71 -71
- package/dist/cli.js +13 -13
- package/dist/entry.js +15 -919
- package/dist/index.d.ts +92 -25
- package/dist/index.js +8 -8
- package/dist/node.d.ts +25 -7
- package/dist/node.js +12 -12
- package/dist/spy.js +2 -102
- package/dist/vendor-_commonjsHelpers.addc3445.js +3 -0
- package/dist/vendor-entry.369fd6c9.js +949 -0
- package/dist/vendor-index.405e58ef.js +6291 -0
- package/dist/{vendor-index.87b2fc14.js → vendor-index.40be925a.js} +167 -152
- package/dist/worker.js +6 -6
- package/package.json +11 -11
- package/dist/chunk-integrations-globals.c040aaa9.js +0 -23
- package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -7
- package/dist/vendor-index.ee829ed6.js +0 -5707
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,36 @@ declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
|
|
|
202
202
|
get(fsPath: string): ModuleCache$1 | undefined;
|
|
203
203
|
delete(fsPath: string): boolean;
|
|
204
204
|
}
|
|
205
|
+
declare class ViteNodeRunner {
|
|
206
|
+
options: ViteNodeRunnerOptions;
|
|
207
|
+
root: string;
|
|
208
|
+
debug: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Holds the cache of modules
|
|
211
|
+
* Keys of the map are filepaths, or plain package names
|
|
212
|
+
*/
|
|
213
|
+
moduleCache: ModuleCacheMap;
|
|
214
|
+
constructor(options: ViteNodeRunnerOptions);
|
|
215
|
+
executeFile(file: string): Promise<any>;
|
|
216
|
+
executeId(id: string): Promise<any>;
|
|
217
|
+
/** @internal */
|
|
218
|
+
cachedRequest(rawId: string, callstack: string[]): Promise<any>;
|
|
219
|
+
/** @internal */
|
|
220
|
+
directRequest(id: string, fsPath: string, _callstack: string[]): Promise<any>;
|
|
221
|
+
prepareContext(context: Record<string, any>): Record<string, any>;
|
|
222
|
+
shouldResolveId(dep: string): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Define if a module should be interop-ed
|
|
225
|
+
* This function mostly for the ability to override by subclass
|
|
226
|
+
*/
|
|
227
|
+
shouldInterop(path: string, mod: any): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Import a module and interop it
|
|
230
|
+
*/
|
|
231
|
+
interopedImport(path: string): Promise<any>;
|
|
232
|
+
hasNestedDefault(target: any): any;
|
|
233
|
+
private debugLog;
|
|
234
|
+
}
|
|
205
235
|
|
|
206
236
|
interface DepsHandlingOptions {
|
|
207
237
|
external?: (string | RegExp)[];
|
|
@@ -229,11 +259,22 @@ interface FetchResult {
|
|
|
229
259
|
map?: RawSourceMap;
|
|
230
260
|
}
|
|
231
261
|
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
262
|
+
declare type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
232
263
|
interface ModuleCache$1 {
|
|
233
264
|
promise?: Promise<any>;
|
|
234
265
|
exports?: any;
|
|
235
266
|
code?: string;
|
|
236
267
|
}
|
|
268
|
+
interface ViteNodeRunnerOptions {
|
|
269
|
+
root: string;
|
|
270
|
+
fetchModule: FetchFunction;
|
|
271
|
+
resolveId?: ResolveIdFunction$1;
|
|
272
|
+
base?: string;
|
|
273
|
+
moduleCache?: ModuleCacheMap;
|
|
274
|
+
interopDefault?: boolean;
|
|
275
|
+
requestStubs?: Record<string, any>;
|
|
276
|
+
debug?: boolean;
|
|
277
|
+
}
|
|
237
278
|
interface ViteNodeResolveId {
|
|
238
279
|
external?: boolean | 'absolute' | 'relative';
|
|
239
280
|
id: string;
|
|
@@ -331,6 +372,7 @@ declare class Vitest {
|
|
|
331
372
|
closingPromise?: Promise<void>;
|
|
332
373
|
isFirstRun: boolean;
|
|
333
374
|
restartsCount: number;
|
|
375
|
+
runner: ViteNodeRunner;
|
|
334
376
|
private _onRestartListeners;
|
|
335
377
|
constructor();
|
|
336
378
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
@@ -345,6 +387,7 @@ declare class Vitest {
|
|
|
345
387
|
updateSnapshot(files?: string[]): Promise<void>;
|
|
346
388
|
log(...args: any[]): void;
|
|
347
389
|
error(...args: any[]): void;
|
|
390
|
+
clearScreen(): void;
|
|
348
391
|
private _rerunTimer;
|
|
349
392
|
private scheduleRerun;
|
|
350
393
|
private unregisterWatcher;
|
|
@@ -712,15 +755,16 @@ interface File extends Suite {
|
|
|
712
755
|
filepath: string;
|
|
713
756
|
collectDuration?: number;
|
|
714
757
|
}
|
|
715
|
-
interface Test extends TaskBase {
|
|
758
|
+
interface Test<ExtraContext = {}> extends TaskBase {
|
|
716
759
|
type: 'test';
|
|
717
760
|
suite: Suite;
|
|
718
761
|
result?: TaskResult;
|
|
719
762
|
fails?: boolean;
|
|
763
|
+
context: TestContext & ExtraContext;
|
|
720
764
|
}
|
|
721
765
|
declare type Task = Test | Suite | File;
|
|
722
766
|
declare type DoneCallback = (error?: any) => void;
|
|
723
|
-
declare type TestFunction = (
|
|
767
|
+
declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<void>;
|
|
724
768
|
declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
725
769
|
1: [T[0]];
|
|
726
770
|
2: [T[0], T[1]];
|
|
@@ -735,36 +779,37 @@ declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
|
735
779
|
fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
|
|
736
780
|
}[T extends Readonly<[any]> ? 1 : T extends Readonly<[any, any]> ? 2 : T extends Readonly<[any, any, any]> ? 3 : T extends Readonly<[any, any, any, any]> ? 4 : T extends Readonly<[any, any, any, any, any]> ? 5 : T extends Readonly<[any, any, any, any, any, any]> ? 6 : T extends Readonly<[any, any, any, any, any, any, any]> ? 7 : T extends Readonly<[any, any, any, any, any, any, any, any]> ? 8 : T extends Readonly<[any, any, any, any, any, any, any, any, any]> ? 9 : T extends Readonly<[any, any, any, any, any, any, any, any, any, any]> ? 10 : 'fallback'];
|
|
737
781
|
interface EachFunction {
|
|
738
|
-
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => void) => void;
|
|
739
|
-
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => void) => void;
|
|
740
|
-
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => void) => void;
|
|
782
|
+
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => Awaitable<void>) => void;
|
|
783
|
+
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
|
|
784
|
+
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
741
785
|
}
|
|
742
|
-
declare type TestAPI = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
786
|
+
declare type TestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
743
787
|
name: string,
|
|
744
|
-
fn?: TestFunction
|
|
788
|
+
fn?: TestFunction<ExtraContext>,
|
|
745
789
|
timeout?: number
|
|
746
790
|
], void> & {
|
|
747
791
|
each: EachFunction;
|
|
748
792
|
};
|
|
749
|
-
declare type SuiteAPI = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo', [
|
|
793
|
+
declare type SuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo', [
|
|
750
794
|
name: string,
|
|
751
795
|
factory?: SuiteFactory
|
|
752
|
-
], SuiteCollector
|
|
796
|
+
], SuiteCollector<ExtraContext>> & {
|
|
753
797
|
each: EachFunction;
|
|
754
798
|
};
|
|
755
|
-
declare type HookListener<T extends any[]> = (...args: T) => Awaitable<void>;
|
|
799
|
+
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
|
|
756
800
|
interface SuiteHooks {
|
|
757
|
-
beforeAll: HookListener<[Suite]
|
|
801
|
+
beforeAll: HookListener<[Suite], () => Awaitable<void>>[];
|
|
758
802
|
afterAll: HookListener<[Suite]>[];
|
|
759
|
-
beforeEach: HookListener<[
|
|
760
|
-
afterEach: HookListener<[
|
|
803
|
+
beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
|
|
804
|
+
afterEach: HookListener<[TestContext, Suite]>[];
|
|
761
805
|
}
|
|
762
|
-
|
|
806
|
+
declare type HookCleanupCallback = (() => Awaitable<void>) | void;
|
|
807
|
+
interface SuiteCollector<ExtraContext = {}> {
|
|
763
808
|
readonly name: string;
|
|
764
809
|
readonly mode: RunMode;
|
|
765
810
|
type: 'collector';
|
|
766
|
-
test: TestAPI
|
|
767
|
-
tasks: (Suite | Test | SuiteCollector)[];
|
|
811
|
+
test: TestAPI<ExtraContext>;
|
|
812
|
+
tasks: (Suite | Test | SuiteCollector<ExtraContext>)[];
|
|
768
813
|
collect: (file?: File) => Promise<Suite>;
|
|
769
814
|
clear: () => void;
|
|
770
815
|
on: <T extends keyof SuiteHooks>(name: T, ...fn: SuiteHooks[T]) => void;
|
|
@@ -774,6 +819,20 @@ interface RuntimeContext {
|
|
|
774
819
|
tasks: (SuiteCollector | Test)[];
|
|
775
820
|
currentSuite: SuiteCollector | null;
|
|
776
821
|
}
|
|
822
|
+
interface TestContext {
|
|
823
|
+
/**
|
|
824
|
+
* @deprecated Use promise instead
|
|
825
|
+
*/
|
|
826
|
+
(error?: any): void;
|
|
827
|
+
/**
|
|
828
|
+
* Metadata of the current test
|
|
829
|
+
*/
|
|
830
|
+
meta: Readonly<Test>;
|
|
831
|
+
/**
|
|
832
|
+
* A expect instance bound to the test
|
|
833
|
+
*/
|
|
834
|
+
expect: Vi.ExpectStatic;
|
|
835
|
+
}
|
|
777
836
|
|
|
778
837
|
interface Reporter {
|
|
779
838
|
onInit?(ctx: Vitest): void;
|
|
@@ -938,9 +997,10 @@ interface InlineConfig {
|
|
|
938
997
|
*/
|
|
939
998
|
root?: string;
|
|
940
999
|
/**
|
|
941
|
-
* Custom reporter for output
|
|
1000
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
1001
|
+
* and/or paths to custom reporters
|
|
942
1002
|
*/
|
|
943
|
-
reporters?: Arrayable<BuiltinReporters | Reporter>;
|
|
1003
|
+
reporters?: Arrayable<BuiltinReporters | Reporter | string>;
|
|
944
1004
|
/**
|
|
945
1005
|
* diff output length
|
|
946
1006
|
*/
|
|
@@ -1181,16 +1241,21 @@ interface WorkerGlobalState {
|
|
|
1181
1241
|
mockMap: MockMap;
|
|
1182
1242
|
}
|
|
1183
1243
|
|
|
1184
|
-
declare const suite: SuiteAPI
|
|
1185
|
-
declare const test: TestAPI
|
|
1186
|
-
declare const describe: SuiteAPI
|
|
1187
|
-
declare const it: TestAPI
|
|
1244
|
+
declare const suite: SuiteAPI<{}>;
|
|
1245
|
+
declare const test: TestAPI<{}>;
|
|
1246
|
+
declare const describe: SuiteAPI<{}>;
|
|
1247
|
+
declare const it: TestAPI<{}>;
|
|
1188
1248
|
|
|
1189
1249
|
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
|
|
1190
1250
|
declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undefined) => void;
|
|
1191
1251
|
declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
|
|
1192
1252
|
declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
|
|
1193
1253
|
|
|
1254
|
+
/**
|
|
1255
|
+
* A simple wrapper for converting callback style to promise
|
|
1256
|
+
*/
|
|
1257
|
+
declare function withCallback(fn: (done: DoneCallback) => void): Promise<void>;
|
|
1258
|
+
|
|
1194
1259
|
/**
|
|
1195
1260
|
* This utils allows computational intensive tasks to only be ran once
|
|
1196
1261
|
* across test reruns to improve the watch mode performance.
|
|
@@ -1210,8 +1275,6 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
|
|
|
1210
1275
|
*/
|
|
1211
1276
|
declare function isFirstRun(): boolean;
|
|
1212
1277
|
|
|
1213
|
-
declare const expect: Vi.ExpectStatic;
|
|
1214
|
-
|
|
1215
1278
|
interface MockResultReturn<T> {
|
|
1216
1279
|
type: 'return';
|
|
1217
1280
|
value: T;
|
|
@@ -1292,6 +1355,9 @@ declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>
|
|
|
1292
1355
|
declare function fn<TArgs extends any[] = any[], R = any>(): SpyInstanceFn<TArgs, R>;
|
|
1293
1356
|
declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): SpyInstanceFn<TArgs, R>;
|
|
1294
1357
|
|
|
1358
|
+
declare function createExpect(test?: Test): Vi.ExpectStatic;
|
|
1359
|
+
declare const expect: Vi.ExpectStatic;
|
|
1360
|
+
|
|
1295
1361
|
declare class VitestUtils {
|
|
1296
1362
|
private _timers;
|
|
1297
1363
|
private _mockedDate;
|
|
@@ -1500,6 +1566,7 @@ declare global {
|
|
|
1500
1566
|
lastReturnedWith<E>(value: E): void;
|
|
1501
1567
|
toHaveNthReturnedWith<E>(nthCall: number, value: E): void;
|
|
1502
1568
|
nthReturnedWith<E>(nthCall: number, value: E): void;
|
|
1569
|
+
toSatisfy<E>(matcher: (value: E) => boolean, message?: string): void;
|
|
1503
1570
|
}
|
|
1504
1571
|
type VitestAssertion<A, T> = {
|
|
1505
1572
|
[K in keyof A]: A[K] extends Chai.Assertion ? Assertion<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T>;
|
|
@@ -1511,4 +1578,4 @@ declare global {
|
|
|
1511
1578
|
}
|
|
1512
1579
|
}
|
|
1513
1580
|
|
|
1514
|
-
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyContext, SpyInstance, SpyInstanceFn, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestFunction, TransformResultWithSource, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest };
|
|
1581
|
+
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyContext, SpyInstance, SpyInstanceFn, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TransformResultWithSource, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, createExpect, describe, expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.f863f182.js';
|
|
2
2
|
export { assert, default as chai, should } from 'chai';
|
|
3
|
-
import '
|
|
4
|
-
import './chunk-
|
|
5
|
-
import '
|
|
3
|
+
import './vendor-_commonjsHelpers.addc3445.js';
|
|
4
|
+
import './chunk-runtime-rpc.8f648236.js';
|
|
5
|
+
import './chunk-utils-global.37a7c822.js';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
|
-
import '
|
|
9
|
-
import './vendor-_commonjsHelpers.34b404ce.js';
|
|
10
|
-
import './chunk-runtime-rpc.4b80b6bd.js';
|
|
8
|
+
import 'path';
|
|
11
9
|
import 'fs';
|
|
12
|
-
import './
|
|
10
|
+
import './chunk-utils-timers.12bc05d1.js';
|
|
11
|
+
import './chunk-integrations-spy.f036df6f.js';
|
|
13
12
|
import 'tinyspy';
|
|
13
|
+
import 'util';
|
package/dist/node.d.ts
CHANGED
|
@@ -522,19 +522,34 @@ interface File extends Suite {
|
|
|
522
522
|
filepath: string;
|
|
523
523
|
collectDuration?: number;
|
|
524
524
|
}
|
|
525
|
-
interface Test extends TaskBase {
|
|
525
|
+
interface Test<ExtraContext = {}> extends TaskBase {
|
|
526
526
|
type: 'test';
|
|
527
527
|
suite: Suite;
|
|
528
528
|
result?: TaskResult;
|
|
529
529
|
fails?: boolean;
|
|
530
|
+
context: TestContext & ExtraContext;
|
|
530
531
|
}
|
|
531
532
|
declare type Task = Test | Suite | File;
|
|
532
|
-
declare type HookListener<T extends any[]> = (...args: T) => Awaitable<void>;
|
|
533
|
+
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
|
|
533
534
|
interface SuiteHooks {
|
|
534
|
-
beforeAll: HookListener<[Suite]
|
|
535
|
+
beforeAll: HookListener<[Suite], () => Awaitable<void>>[];
|
|
535
536
|
afterAll: HookListener<[Suite]>[];
|
|
536
|
-
beforeEach: HookListener<[
|
|
537
|
-
afterEach: HookListener<[
|
|
537
|
+
beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
|
|
538
|
+
afterEach: HookListener<[TestContext, Suite]>[];
|
|
539
|
+
}
|
|
540
|
+
interface TestContext {
|
|
541
|
+
/**
|
|
542
|
+
* @deprecated Use promise instead
|
|
543
|
+
*/
|
|
544
|
+
(error?: any): void;
|
|
545
|
+
/**
|
|
546
|
+
* Metadata of the current test
|
|
547
|
+
*/
|
|
548
|
+
meta: Readonly<Test>;
|
|
549
|
+
/**
|
|
550
|
+
* A expect instance bound to the test
|
|
551
|
+
*/
|
|
552
|
+
expect: Vi.ExpectStatic;
|
|
538
553
|
}
|
|
539
554
|
|
|
540
555
|
interface Reporter {
|
|
@@ -691,9 +706,10 @@ interface InlineConfig {
|
|
|
691
706
|
*/
|
|
692
707
|
root?: string;
|
|
693
708
|
/**
|
|
694
|
-
* Custom reporter for output
|
|
709
|
+
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
|
|
710
|
+
* and/or paths to custom reporters
|
|
695
711
|
*/
|
|
696
|
-
reporters?: Arrayable<BuiltinReporters | Reporter>;
|
|
712
|
+
reporters?: Arrayable<BuiltinReporters | Reporter | string>;
|
|
697
713
|
/**
|
|
698
714
|
* diff output length
|
|
699
715
|
*/
|
|
@@ -942,6 +958,7 @@ declare class Vitest {
|
|
|
942
958
|
closingPromise?: Promise<void>;
|
|
943
959
|
isFirstRun: boolean;
|
|
944
960
|
restartsCount: number;
|
|
961
|
+
runner: ViteNodeRunner;
|
|
945
962
|
private _onRestartListeners;
|
|
946
963
|
constructor();
|
|
947
964
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
@@ -956,6 +973,7 @@ declare class Vitest {
|
|
|
956
973
|
updateSnapshot(files?: string[]): Promise<void>;
|
|
957
974
|
log(...args: any[]): void;
|
|
958
975
|
error(...args: any[]): void;
|
|
976
|
+
clearScreen(): void;
|
|
959
977
|
private _rerunTimer;
|
|
960
978
|
private scheduleRerun;
|
|
961
979
|
private unregisterWatcher;
|
package/dist/node.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.5c678054.js';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.111ac858.js';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'path';
|
|
5
5
|
import 'child_process';
|
|
6
6
|
import 'process';
|
|
7
|
-
import './vendor-index.
|
|
8
|
-
import './vendor-_commonjsHelpers.
|
|
7
|
+
import './vendor-index.40be925a.js';
|
|
8
|
+
import './vendor-_commonjsHelpers.addc3445.js';
|
|
9
9
|
import 'fs';
|
|
10
10
|
import 'assert';
|
|
11
11
|
import 'events';
|
|
@@ -13,19 +13,19 @@ import 'stream';
|
|
|
13
13
|
import 'util';
|
|
14
14
|
import 'url';
|
|
15
15
|
import 'os';
|
|
16
|
-
import './chunk-utils-global.
|
|
16
|
+
import './chunk-utils-global.37a7c822.js';
|
|
17
17
|
import 'tty';
|
|
18
18
|
import 'local-pkg';
|
|
19
19
|
import 'vite';
|
|
20
|
-
import './chunk-constants.
|
|
21
|
-
import '
|
|
20
|
+
import './chunk-constants.d540b1d1.js';
|
|
21
|
+
import 'readline';
|
|
22
|
+
import './chunk-vite-node-utils.33447cc0.js';
|
|
22
23
|
import 'module';
|
|
23
24
|
import 'vm';
|
|
24
|
-
import './chunk-defaults.
|
|
25
|
-
import 'perf_hooks';
|
|
26
|
-
import './chunk-utils-timers.4800834c.js';
|
|
25
|
+
import './chunk-defaults.04d5d90b.js';
|
|
27
26
|
import 'worker_threads';
|
|
28
27
|
import 'tinypool';
|
|
28
|
+
import 'perf_hooks';
|
|
29
|
+
import './chunk-utils-timers.12bc05d1.js';
|
|
29
30
|
import './chunk-magic-string.d5e0e473.js';
|
|
30
|
-
import '
|
|
31
|
-
import './vendor-index.ee829ed6.js';
|
|
31
|
+
import './vendor-index.405e58ef.js';
|
package/dist/spy.js
CHANGED
|
@@ -1,102 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const spies = /* @__PURE__ */ new Set();
|
|
4
|
-
function isMockFunction(fn2) {
|
|
5
|
-
return typeof fn2 === "function" && "_isMockFunction" in fn2 && fn2._isMockFunction;
|
|
6
|
-
}
|
|
7
|
-
function spyOn(obj, method, accessType) {
|
|
8
|
-
const dictionary = {
|
|
9
|
-
get: "getter",
|
|
10
|
-
set: "setter"
|
|
11
|
-
};
|
|
12
|
-
const objMethod = accessType ? { [dictionary[accessType]]: method } : method;
|
|
13
|
-
const stub = tinyspy.spyOn(obj, objMethod);
|
|
14
|
-
return enhanceSpy(stub);
|
|
15
|
-
}
|
|
16
|
-
let callOrder = 0;
|
|
17
|
-
function enhanceSpy(spy) {
|
|
18
|
-
const stub = spy;
|
|
19
|
-
let implementation;
|
|
20
|
-
let instances = [];
|
|
21
|
-
let invocations = [];
|
|
22
|
-
const mockContext = {
|
|
23
|
-
get calls() {
|
|
24
|
-
return stub.calls;
|
|
25
|
-
},
|
|
26
|
-
get instances() {
|
|
27
|
-
return instances;
|
|
28
|
-
},
|
|
29
|
-
get invocationCallOrder() {
|
|
30
|
-
return invocations;
|
|
31
|
-
},
|
|
32
|
-
get results() {
|
|
33
|
-
return stub.results.map(([callType, value]) => {
|
|
34
|
-
const type = callType === "error" ? "throw" : "return";
|
|
35
|
-
return { type, value };
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
get lastCall() {
|
|
39
|
-
return stub.calls.at(-1);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
let onceImplementations = [];
|
|
43
|
-
let name = stub.name;
|
|
44
|
-
stub.getMockName = () => name || "vi.fn()";
|
|
45
|
-
stub.mockName = (n) => {
|
|
46
|
-
name = n;
|
|
47
|
-
return stub;
|
|
48
|
-
};
|
|
49
|
-
stub.mockClear = () => {
|
|
50
|
-
stub.reset();
|
|
51
|
-
instances = [];
|
|
52
|
-
invocations = [];
|
|
53
|
-
return stub;
|
|
54
|
-
};
|
|
55
|
-
stub.mockReset = () => {
|
|
56
|
-
stub.mockClear();
|
|
57
|
-
implementation = () => void 0;
|
|
58
|
-
onceImplementations = [];
|
|
59
|
-
return stub;
|
|
60
|
-
};
|
|
61
|
-
stub.mockRestore = () => {
|
|
62
|
-
stub.mockReset();
|
|
63
|
-
implementation = void 0;
|
|
64
|
-
return stub;
|
|
65
|
-
};
|
|
66
|
-
stub.getMockImplementation = () => implementation;
|
|
67
|
-
stub.mockImplementation = (fn2) => {
|
|
68
|
-
implementation = fn2;
|
|
69
|
-
return stub;
|
|
70
|
-
};
|
|
71
|
-
stub.mockImplementationOnce = (fn2) => {
|
|
72
|
-
onceImplementations.push(fn2);
|
|
73
|
-
return stub;
|
|
74
|
-
};
|
|
75
|
-
stub.mockReturnThis = () => stub.mockImplementation(function() {
|
|
76
|
-
return this;
|
|
77
|
-
});
|
|
78
|
-
stub.mockReturnValue = (val) => stub.mockImplementation(() => val);
|
|
79
|
-
stub.mockReturnValueOnce = (val) => stub.mockImplementationOnce(() => val);
|
|
80
|
-
stub.mockResolvedValue = (val) => stub.mockImplementation(() => Promise.resolve(val));
|
|
81
|
-
stub.mockResolvedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.resolve(val));
|
|
82
|
-
stub.mockRejectedValue = (val) => stub.mockImplementation(() => Promise.reject(val));
|
|
83
|
-
stub.mockRejectedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.reject(val));
|
|
84
|
-
Object.defineProperty(stub, "mock", {
|
|
85
|
-
get: () => mockContext
|
|
86
|
-
});
|
|
87
|
-
stub.willCall(function(...args) {
|
|
88
|
-
instances.push(this);
|
|
89
|
-
invocations.push(++callOrder);
|
|
90
|
-
const impl = onceImplementations.shift() || implementation || stub.getOriginal() || (() => {
|
|
91
|
-
});
|
|
92
|
-
return impl.apply(this, args);
|
|
93
|
-
});
|
|
94
|
-
spies.add(stub);
|
|
95
|
-
return stub;
|
|
96
|
-
}
|
|
97
|
-
function fn(implementation) {
|
|
98
|
-
return enhanceSpy(tinyspy.spyOn({ fn: implementation || (() => {
|
|
99
|
-
}) }, "fn"));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { fn, isMockFunction, spies, spyOn };
|
|
1
|
+
export { f as fn, i as isMockFunction, a as spies, s as spyOn } from './chunk-integrations-spy.f036df6f.js';
|
|
2
|
+
import 'tinyspy';
|