vitest 0.9.4 → 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.49283db8.js → chunk-api-setup.d70fc960.js} +5 -5
- package/dist/{chunk-constants.c8f1d38c.js → chunk-constants.d540b1d1.js} +1 -1
- package/dist/{chunk-defaults.43e746f3.js → chunk-defaults.04d5d90b.js} +1 -1
- package/dist/{chunk-install-pkg.cbf3a38b.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.701cffd8.js → chunk-runtime-chain.f863f182.js} +931 -897
- package/dist/{chunk-runtime-mocker.e802beae.js → chunk-runtime-mocker.111ac858.js} +3 -3
- package/dist/{chunk-runtime-rpc.c47f2233.js → chunk-runtime-rpc.8f648236.js} +1 -1
- package/dist/{chunk-utils-global.a3293dce.js → chunk-utils-global.37a7c822.js} +8 -10
- package/dist/{chunk-utils-timers.b26e7c5c.js → chunk-utils-timers.12bc05d1.js} +1404 -1057
- package/dist/{chunk-vite-node-externalize.1c19fc5e.js → chunk-vite-node-externalize.5c678054.js} +544 -517
- package/dist/{chunk-vite-node-utils.b4debb0b.js → chunk-vite-node-utils.33447cc0.js} +71 -71
- package/dist/cli.js +12 -12
- package/dist/entry.js +15 -919
- package/dist/index.d.ts +90 -25
- package/dist/index.js +8 -8
- package/dist/node.d.ts +24 -7
- package/dist/node.js +11 -11
- 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.bd255bc8.js → vendor-index.40be925a.js} +173 -158
- package/dist/worker.js +6 -6
- package/package.json +4 -4
- package/dist/chunk-integrations-globals.b4a20711.js +0 -23
- package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -7
- package/dist/vendor-index.13468339.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>;
|
|
@@ -713,15 +755,16 @@ interface File extends Suite {
|
|
|
713
755
|
filepath: string;
|
|
714
756
|
collectDuration?: number;
|
|
715
757
|
}
|
|
716
|
-
interface Test extends TaskBase {
|
|
758
|
+
interface Test<ExtraContext = {}> extends TaskBase {
|
|
717
759
|
type: 'test';
|
|
718
760
|
suite: Suite;
|
|
719
761
|
result?: TaskResult;
|
|
720
762
|
fails?: boolean;
|
|
763
|
+
context: TestContext & ExtraContext;
|
|
721
764
|
}
|
|
722
765
|
declare type Task = Test | Suite | File;
|
|
723
766
|
declare type DoneCallback = (error?: any) => void;
|
|
724
|
-
declare type TestFunction = (
|
|
767
|
+
declare type TestFunction<ExtraContext = {}> = (context: TestContext & ExtraContext) => Awaitable<void>;
|
|
725
768
|
declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
726
769
|
1: [T[0]];
|
|
727
770
|
2: [T[0], T[1]];
|
|
@@ -736,36 +779,37 @@ declare type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
|
|
|
736
779
|
fallback: Array<T extends ReadonlyArray<infer U> ? U : any>;
|
|
737
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'];
|
|
738
781
|
interface EachFunction {
|
|
739
|
-
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => void) => void;
|
|
740
|
-
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => void) => void;
|
|
741
|
-
<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;
|
|
742
785
|
}
|
|
743
|
-
declare type TestAPI = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
786
|
+
declare type TestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
744
787
|
name: string,
|
|
745
|
-
fn?: TestFunction
|
|
788
|
+
fn?: TestFunction<ExtraContext>,
|
|
746
789
|
timeout?: number
|
|
747
790
|
], void> & {
|
|
748
791
|
each: EachFunction;
|
|
749
792
|
};
|
|
750
|
-
declare type SuiteAPI = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo', [
|
|
793
|
+
declare type SuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo', [
|
|
751
794
|
name: string,
|
|
752
795
|
factory?: SuiteFactory
|
|
753
|
-
], SuiteCollector
|
|
796
|
+
], SuiteCollector<ExtraContext>> & {
|
|
754
797
|
each: EachFunction;
|
|
755
798
|
};
|
|
756
|
-
declare type HookListener<T extends any[]> = (...args: T) => Awaitable<void>;
|
|
799
|
+
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
|
|
757
800
|
interface SuiteHooks {
|
|
758
|
-
beforeAll: HookListener<[Suite]
|
|
801
|
+
beforeAll: HookListener<[Suite], () => Awaitable<void>>[];
|
|
759
802
|
afterAll: HookListener<[Suite]>[];
|
|
760
|
-
beforeEach: HookListener<[
|
|
761
|
-
afterEach: HookListener<[
|
|
803
|
+
beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
|
|
804
|
+
afterEach: HookListener<[TestContext, Suite]>[];
|
|
762
805
|
}
|
|
763
|
-
|
|
806
|
+
declare type HookCleanupCallback = (() => Awaitable<void>) | void;
|
|
807
|
+
interface SuiteCollector<ExtraContext = {}> {
|
|
764
808
|
readonly name: string;
|
|
765
809
|
readonly mode: RunMode;
|
|
766
810
|
type: 'collector';
|
|
767
|
-
test: TestAPI
|
|
768
|
-
tasks: (Suite | Test | SuiteCollector)[];
|
|
811
|
+
test: TestAPI<ExtraContext>;
|
|
812
|
+
tasks: (Suite | Test | SuiteCollector<ExtraContext>)[];
|
|
769
813
|
collect: (file?: File) => Promise<Suite>;
|
|
770
814
|
clear: () => void;
|
|
771
815
|
on: <T extends keyof SuiteHooks>(name: T, ...fn: SuiteHooks[T]) => void;
|
|
@@ -775,6 +819,20 @@ interface RuntimeContext {
|
|
|
775
819
|
tasks: (SuiteCollector | Test)[];
|
|
776
820
|
currentSuite: SuiteCollector | null;
|
|
777
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
|
+
}
|
|
778
836
|
|
|
779
837
|
interface Reporter {
|
|
780
838
|
onInit?(ctx: Vitest): void;
|
|
@@ -939,9 +997,10 @@ interface InlineConfig {
|
|
|
939
997
|
*/
|
|
940
998
|
root?: string;
|
|
941
999
|
/**
|
|
942
|
-
* 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
|
|
943
1002
|
*/
|
|
944
|
-
reporters?: Arrayable<BuiltinReporters | Reporter>;
|
|
1003
|
+
reporters?: Arrayable<BuiltinReporters | Reporter | string>;
|
|
945
1004
|
/**
|
|
946
1005
|
* diff output length
|
|
947
1006
|
*/
|
|
@@ -1182,16 +1241,21 @@ interface WorkerGlobalState {
|
|
|
1182
1241
|
mockMap: MockMap;
|
|
1183
1242
|
}
|
|
1184
1243
|
|
|
1185
|
-
declare const suite: SuiteAPI
|
|
1186
|
-
declare const test: TestAPI
|
|
1187
|
-
declare const describe: SuiteAPI
|
|
1188
|
-
declare const it: TestAPI
|
|
1244
|
+
declare const suite: SuiteAPI<{}>;
|
|
1245
|
+
declare const test: TestAPI<{}>;
|
|
1246
|
+
declare const describe: SuiteAPI<{}>;
|
|
1247
|
+
declare const it: TestAPI<{}>;
|
|
1189
1248
|
|
|
1190
1249
|
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
|
|
1191
1250
|
declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undefined) => void;
|
|
1192
1251
|
declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
|
|
1193
1252
|
declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
|
|
1194
1253
|
|
|
1254
|
+
/**
|
|
1255
|
+
* A simple wrapper for converting callback style to promise
|
|
1256
|
+
*/
|
|
1257
|
+
declare function withCallback(fn: (done: DoneCallback) => void): Promise<void>;
|
|
1258
|
+
|
|
1195
1259
|
/**
|
|
1196
1260
|
* This utils allows computational intensive tasks to only be ran once
|
|
1197
1261
|
* across test reruns to improve the watch mode performance.
|
|
@@ -1211,8 +1275,6 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
|
|
|
1211
1275
|
*/
|
|
1212
1276
|
declare function isFirstRun(): boolean;
|
|
1213
1277
|
|
|
1214
|
-
declare const expect: Vi.ExpectStatic;
|
|
1215
|
-
|
|
1216
1278
|
interface MockResultReturn<T> {
|
|
1217
1279
|
type: 'return';
|
|
1218
1280
|
value: T;
|
|
@@ -1293,6 +1355,9 @@ declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>
|
|
|
1293
1355
|
declare function fn<TArgs extends any[] = any[], R = any>(): SpyInstanceFn<TArgs, R>;
|
|
1294
1356
|
declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): SpyInstanceFn<TArgs, R>;
|
|
1295
1357
|
|
|
1358
|
+
declare function createExpect(test?: Test): Vi.ExpectStatic;
|
|
1359
|
+
declare const expect: Vi.ExpectStatic;
|
|
1360
|
+
|
|
1296
1361
|
declare class VitestUtils {
|
|
1297
1362
|
private _timers;
|
|
1298
1363
|
private _mockedDate;
|
|
@@ -1513,4 +1578,4 @@ declare global {
|
|
|
1513
1578
|
}
|
|
1514
1579
|
}
|
|
1515
1580
|
|
|
1516
|
-
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.c47f2233.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>;
|
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.
|
|
20
|
+
import './chunk-constants.d540b1d1.js';
|
|
21
21
|
import 'readline';
|
|
22
|
-
import './chunk-vite-node-utils.
|
|
22
|
+
import './chunk-vite-node-utils.33447cc0.js';
|
|
23
23
|
import 'module';
|
|
24
24
|
import 'vm';
|
|
25
|
-
import './chunk-defaults.
|
|
26
|
-
import 'perf_hooks';
|
|
27
|
-
import './chunk-utils-timers.b26e7c5c.js';
|
|
25
|
+
import './chunk-defaults.04d5d90b.js';
|
|
28
26
|
import 'worker_threads';
|
|
29
27
|
import 'tinypool';
|
|
28
|
+
import 'perf_hooks';
|
|
29
|
+
import './chunk-utils-timers.12bc05d1.js';
|
|
30
30
|
import './chunk-magic-string.d5e0e473.js';
|
|
31
|
-
import './vendor-index.
|
|
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';
|