vitest 0.17.1 → 0.19.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.
Files changed (37) hide show
  1. package/LICENSE.md +6 -6
  2. package/dist/browser.d.ts +1850 -0
  3. package/dist/browser.mjs +20 -0
  4. package/dist/{chunk-api-setup.c728e251.mjs → chunk-api-setup.0cf2c96a.mjs} +37 -11
  5. package/dist/{chunk-constants.27550afb.mjs → chunk-constants.38b43a44.mjs} +3 -3
  6. package/dist/{chunk-env-node.aa51c4cc.mjs → chunk-defaults.408a0cfe.mjs} +457 -455
  7. package/dist/{chunk-install-pkg.6f5930c3.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
  8. package/dist/chunk-integrations-globals.803277be.mjs +24 -0
  9. package/dist/chunk-node-git.9058b82a.mjs +1139 -0
  10. package/dist/chunk-runtime-chain.1e1aabb3.mjs +2025 -0
  11. package/dist/{vendor-entry.1ad8a08d.mjs → chunk-runtime-error.d82dd2cf.mjs} +167 -183
  12. package/dist/{chunk-runtime-chain.6d23d202.mjs → chunk-runtime-hooks.db398170.mjs} +33 -2012
  13. package/dist/{chunk-runtime-mocker.34b9d585.mjs → chunk-runtime-mocker.dfdfd57b.mjs} +70 -22
  14. package/dist/{chunk-runtime-rpc.d986adb9.mjs → chunk-runtime-rpc.45d8ee19.mjs} +1 -1
  15. package/dist/{chunk-utils-global.4828c2e2.mjs → chunk-utils-global.2aa95025.mjs} +14 -9
  16. package/dist/{chunk-utils-source-map.a9047343.mjs → chunk-utils-source-map.8b066ce2.mjs} +2 -2
  17. package/dist/{chunk-vite-node-externalize.0fc8ed68.mjs → chunk-vite-node-externalize.a2813ad7.mjs} +1202 -2178
  18. package/dist/chunk-vite-node-utils.ad73f2ab.mjs +1433 -0
  19. package/dist/cli.mjs +11 -13
  20. package/dist/config.cjs +4 -1
  21. package/dist/config.d.ts +1 -0
  22. package/dist/config.mjs +4 -1
  23. package/dist/entry.mjs +54 -10
  24. package/dist/index.d.ts +126 -58
  25. package/dist/index.mjs +12 -9
  26. package/dist/node.d.ts +109 -58
  27. package/dist/node.mjs +12 -14
  28. package/dist/spy.mjs +102 -2
  29. package/dist/suite.mjs +13 -0
  30. package/dist/vendor-index.61438b77.mjs +335 -0
  31. package/dist/{vendor-index.a2a385d8.mjs → vendor-index.62ce5c33.mjs} +6 -338
  32. package/dist/{vendor-index.98e769c1.mjs → vendor-index.de788b6a.mjs} +7 -7
  33. package/dist/worker.mjs +6 -6
  34. package/package.json +20 -12
  35. package/dist/chunk-integrations-globals.3df36e26.mjs +0 -26
  36. package/dist/chunk-integrations-spy.674b628e.mjs +0 -102
  37. package/dist/chunk-vite-node-utils.0f776286.mjs +0 -9195
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ViteDevServer, TransformResult, CommonServerOptions, UserConfig as UserConfig$1, Plugin as Plugin$1 } from 'vite';
1
+ import { ViteDevServer, TransformResult, AliasOptions, CommonServerOptions, UserConfig as UserConfig$1, Plugin as Plugin$1 } from 'vite';
2
2
  import { Stats } from 'fs';
3
3
 
4
4
  interface UpdatePayload {
@@ -51,26 +51,18 @@ interface CustomEventMap {
51
51
  type InferCustomEventPayload<T extends string> =
52
52
  T extends keyof CustomEventMap ? CustomEventMap[T] : any
53
53
 
54
- type ModuleNamespace = Record<string, any> & {
55
- [Symbol.toStringTag]: 'Module'
56
- }
57
-
58
54
  interface ViteHotContext {
59
55
  readonly data: any
60
56
 
61
57
  accept(): void
62
- accept(cb: (mod: ModuleNamespace | undefined) => void): void
63
- accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
64
- accept(
65
- deps: readonly string[],
66
- cb: (mods: Array<ModuleNamespace | undefined>) => void
67
- ): void
58
+ accept(cb: (mod: any) => void): void
59
+ accept(dep: string, cb: (mod: any) => void): void
60
+ accept(deps: readonly string[], cb: (mods: any[]) => void): void
68
61
 
69
- acceptExports(exportNames: string | readonly string[]): void
70
- acceptExports(
71
- exportNames: string | readonly string[],
72
- cb: (mod: ModuleNamespace | undefined) => void
73
- ): void
62
+ /**
63
+ * @deprecated
64
+ */
65
+ acceptDeps(): never
74
66
 
75
67
  dispose(cb: (data: any) => void): void
76
68
  decline(): void
@@ -365,14 +357,19 @@ declare abstract class BaseReporter implements Reporter {
365
357
  start: number;
366
358
  end: number;
367
359
  watchFilters?: string[];
368
- isTTY: boolean;
360
+ isTTY: false;
369
361
  ctx: Vitest;
362
+ private _filesInWatchMode;
363
+ private _lastRunTimeout;
364
+ private _lastRunTimer;
365
+ private _lastRunCount;
370
366
  constructor();
371
367
  onInit(ctx: Vitest): void;
372
368
  relative(path: string): string;
373
369
  onFinished(files?: File[], errors?: unknown[]): Promise<void>;
374
370
  onTaskUpdate(packs: TaskResultPack[]): void;
375
371
  onWatcherStart(): Promise<void>;
372
+ private resetLastRunLog;
376
373
  onWatcherRerun(files: string[], trigger?: string): Promise<void>;
377
374
  onUserConsoleLog(log: UserConsoleLog): void;
378
375
  shouldLog(log: UserConsoleLog): boolean;
@@ -382,9 +379,35 @@ declare abstract class BaseReporter implements Reporter {
382
379
  registerUnhandledRejection(): void;
383
380
  }
384
381
 
382
+ declare class Logger {
383
+ ctx: Vitest;
384
+ console: Console;
385
+ outputStream: NodeJS.WriteStream & {
386
+ fd: 1;
387
+ };
388
+ errorStream: NodeJS.WriteStream & {
389
+ fd: 2;
390
+ };
391
+ logUpdate: ((...text: string[]) => void) & {
392
+ clear(): void;
393
+ done(): void;
394
+ };
395
+ private _clearScreenPending;
396
+ constructor(ctx: Vitest, console?: Console);
397
+ log(...args: any[]): void;
398
+ error(...args: any[]): void;
399
+ warn(...args: any[]): void;
400
+ clearScreen(message: string, force?: boolean): void;
401
+ private _clearScreen;
402
+ printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
403
+ printNoTestFound(filters?: string[]): void;
404
+ printBanner(): void;
405
+ printUnhandledErrors(errors: unknown[]): Promise<void>;
406
+ }
407
+
385
408
  interface ListRendererOptions {
386
409
  renderSucceed?: boolean;
387
- outputStream: NodeJS.WritableStream;
410
+ logger: Logger;
388
411
  showHeap: boolean;
389
412
  }
390
413
  declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
@@ -416,6 +439,10 @@ declare class DotReporter extends BaseReporter {
416
439
  onUserConsoleLog(log: UserConsoleLog): void;
417
440
  }
418
441
 
442
+ interface Callsite {
443
+ line: number;
444
+ column: number;
445
+ }
419
446
  declare class JsonReporter implements Reporter {
420
447
  start: number;
421
448
  ctx: Vitest;
@@ -428,6 +455,7 @@ declare class JsonReporter implements Reporter {
428
455
  * @param report
429
456
  */
430
457
  writeReport(report: string): Promise<void>;
458
+ protected getFailureLocation(test: Test): Callsite | undefined;
431
459
  }
432
460
 
433
461
  declare class VerboseReporter extends DefaultReporter {
@@ -482,7 +510,7 @@ interface TestSequencer {
482
510
  shard(files: string[]): Awaitable<string[]>;
483
511
  sort(files: string[]): Awaitable<string[]>;
484
512
  }
485
- interface TestSequencerContructor {
513
+ interface TestSequencerConstructor {
486
514
  new (ctx: Vitest): TestSequencer;
487
515
  }
488
516
 
@@ -727,6 +755,7 @@ interface TestContext {
727
755
 
728
756
  interface Reporter {
729
757
  onInit?(ctx: Vitest): void;
758
+ onPathsCollected?: (paths?: string[]) => Awaitable<void>;
730
759
  onCollected?: (files?: File[]) => Awaitable<void>;
731
760
  onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
732
761
  onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
@@ -936,6 +965,12 @@ interface InlineConfig {
936
965
  * @default 10000
937
966
  */
938
967
  hookTimeout?: number;
968
+ /**
969
+ * Default timeout to wait for close when Vitest shuts down, in milliseconds
970
+ *
971
+ * @default 1000
972
+ */
973
+ teardownTimeout?: number;
939
974
  /**
940
975
  * Silent mode
941
976
  *
@@ -1004,6 +1039,11 @@ interface InlineConfig {
1004
1039
  * @internal WIP
1005
1040
  */
1006
1041
  ui?: boolean;
1042
+ /**
1043
+ * Use in browser environment
1044
+ * @experimental
1045
+ */
1046
+ browser?: boolean;
1007
1047
  /**
1008
1048
  * Open UI automatically.
1009
1049
  *
@@ -1103,7 +1143,7 @@ interface InlineConfig {
1103
1143
  * your custom sequencer from `BaseSequencer` from `vitest/node`.
1104
1144
  * @default BaseSequencer
1105
1145
  */
1106
- sequencer?: TestSequencerContructor;
1146
+ sequencer?: TestSequencerConstructor;
1107
1147
  /**
1108
1148
  * Should tests run in random order.
1109
1149
  * @default false
@@ -1115,6 +1155,12 @@ interface InlineConfig {
1115
1155
  */
1116
1156
  seed?: number;
1117
1157
  };
1158
+ /**
1159
+ * Specifies an `Object`, or an `Array` of `Object`,
1160
+ * which defines aliases used to replace values in `import` or `require` statements.
1161
+ * Will be merged with the default aliases inside `resolve.alias`.
1162
+ */
1163
+ alias?: AliasOptions;
1118
1164
  }
1119
1165
  interface UserConfig extends InlineConfig {
1120
1166
  /**
@@ -1173,7 +1219,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
1173
1219
  dir: string;
1174
1220
  } | false;
1175
1221
  sequence: {
1176
- sequencer: TestSequencerContructor;
1222
+ sequencer: TestSequencerConstructor;
1177
1223
  shuffle?: boolean;
1178
1224
  seed?: number;
1179
1225
  };
@@ -1457,6 +1503,27 @@ interface WorkerPool {
1457
1503
  close: () => Promise<void>;
1458
1504
  }
1459
1505
 
1506
+ declare class StateManager {
1507
+ filesMap: Map<string, File>;
1508
+ pathsSet: Set<string>;
1509
+ idMap: Map<string, Task>;
1510
+ taskFileMap: WeakMap<Task, File>;
1511
+ errorsSet: Set<unknown>;
1512
+ catchError(err: unknown, type: string): void;
1513
+ clearErrors(): void;
1514
+ getUnhandledErrors(): unknown[];
1515
+ getPaths(): string[];
1516
+ getFiles(keys?: string[]): File[];
1517
+ getFilepaths(): string[];
1518
+ getFailedFilepaths(): string[];
1519
+ collectPaths(paths?: string[]): void;
1520
+ collectFiles(files?: File[]): void;
1521
+ clearFiles(paths?: string[]): void;
1522
+ updateId(task: Task): void;
1523
+ updateTasks(packs: TaskResultPack[]): void;
1524
+ updateUserLog(log: UserConsoleLog): void;
1525
+ }
1526
+
1460
1527
  interface SuiteResultCache {
1461
1528
  failed: boolean;
1462
1529
  duration: number;
@@ -1466,6 +1533,7 @@ declare class ResultsCache {
1466
1533
  private cachePath;
1467
1534
  private version;
1468
1535
  private root;
1536
+ getCachePath(): string | null;
1469
1537
  setConfig(root: string, config: ResolvedConfig['cache']): void;
1470
1538
  getResults(fsPath: string): SuiteResultCache | undefined;
1471
1539
  readFromCache(): Promise<void>;
@@ -1474,6 +1542,14 @@ declare class ResultsCache {
1474
1542
  writeToCache(): Promise<void>;
1475
1543
  }
1476
1544
 
1545
+ interface CliOptions extends UserConfig {
1546
+ /**
1547
+ * Override the watch mode
1548
+ */
1549
+ run?: boolean;
1550
+ }
1551
+ declare function startVitest(cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
1552
+
1477
1553
  declare type FileStatsCache = Pick<Stats, 'size'>;
1478
1554
  declare class FilesStatsCache {
1479
1555
  cache: Map<string, FileStatsCache>;
@@ -1482,27 +1558,18 @@ declare class FilesStatsCache {
1482
1558
  removeStats(fsPath: string): void;
1483
1559
  }
1484
1560
 
1485
- declare class StateManager {
1486
- filesMap: Map<string, File>;
1487
- idMap: Map<string, Task>;
1488
- taskFileMap: WeakMap<Task, File>;
1489
- errorsSet: Set<unknown>;
1561
+ declare class VitestCache {
1490
1562
  results: ResultsCache;
1491
1563
  stats: FilesStatsCache;
1492
1564
  getFileTestResults(id: string): SuiteResultCache | undefined;
1493
1565
  getFileStats(id: string): {
1494
1566
  size: number;
1495
1567
  } | undefined;
1496
- catchError(err: unknown, type: string): void;
1497
- clearErrors(): void;
1498
- getUnhandledErrors(): unknown[];
1499
- getFiles(keys?: string[]): File[];
1500
- getFilepaths(): string[];
1501
- getFailedFilepaths(): string[];
1502
- collectFiles(files?: File[]): void;
1503
- updateId(task: Task): void;
1504
- updateTasks(packs: TaskResultPack[]): void;
1505
- updateUserLog(log: UserConsoleLog): void;
1568
+ static resolveCacheDir(root: string, dir: string | undefined): string;
1569
+ static clearCache(options: CliOptions): Promise<{
1570
+ dir: string;
1571
+ cleared: boolean;
1572
+ }>;
1506
1573
  }
1507
1574
 
1508
1575
  declare class Vitest {
@@ -1511,15 +1578,10 @@ declare class Vitest {
1511
1578
  server: ViteDevServer;
1512
1579
  state: StateManager;
1513
1580
  snapshot: SnapshotManager;
1581
+ cache: VitestCache;
1514
1582
  reporters: Reporter[];
1515
- console: Console;
1583
+ logger: Logger;
1516
1584
  pool: WorkerPool | undefined;
1517
- outputStream: NodeJS.WriteStream & {
1518
- fd: 1;
1519
- };
1520
- errorStream: NodeJS.WriteStream & {
1521
- fd: 2;
1522
- };
1523
1585
  vitenode: ViteNodeServer;
1524
1586
  invalidates: Set<string>;
1525
1587
  changedTests: Set<string>;
@@ -1528,8 +1590,8 @@ declare class Vitest {
1528
1590
  isFirstRun: boolean;
1529
1591
  restartsCount: number;
1530
1592
  runner: ViteNodeRunner;
1531
- private _onRestartListeners;
1532
1593
  constructor();
1594
+ private _onRestartListeners;
1533
1595
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
1534
1596
  getSerializableConfig(): ResolvedConfig;
1535
1597
  start(filters?: string[]): Promise<void>;
@@ -1540,9 +1602,6 @@ declare class Vitest {
1540
1602
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
1541
1603
  rerunFailed(): Promise<void>;
1542
1604
  updateSnapshot(files?: string[]): Promise<void>;
1543
- log(...args: any[]): void;
1544
- error(...args: any[]): void;
1545
- clearScreen(): void;
1546
1605
  private _rerunTimer;
1547
1606
  private scheduleRerun;
1548
1607
  private unregisterWatcher;
@@ -1557,7 +1616,6 @@ declare class Vitest {
1557
1616
  globTestFiles(filters?: string[]): Promise<string[]>;
1558
1617
  isTargetFile(id: string, source?: string): Promise<boolean>;
1559
1618
  isInSourceTestFile(code: string): boolean;
1560
- printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
1561
1619
  onServerRestarted(fn: () => void): void;
1562
1620
  }
1563
1621
 
@@ -1565,14 +1623,7 @@ declare function createVitest(options: UserConfig, viteOverrides?: UserConfig$1)
1565
1623
 
1566
1624
  declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin$1[]>;
1567
1625
 
1568
- interface CliOptions extends UserConfig {
1569
- /**
1570
- * Override the watch mode
1571
- */
1572
- run?: boolean;
1573
- }
1574
- declare function startVitest(cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
1575
-
1626
+ declare type Key = string | symbol;
1576
1627
  interface ViteRunnerRequest {
1577
1628
  (dep: string): any;
1578
1629
  callstack: string[];
@@ -1598,7 +1649,7 @@ declare class VitestMocker {
1598
1649
  normalizePath(path: string): string;
1599
1650
  getFsPath(path: string, external: string | null): string;
1600
1651
  resolveMockPath(mockPath: string, external: string | null): string | null;
1601
- mockValue(value: any): any;
1652
+ mockObject(object: Record<string | symbol, any>): Record<Key, any>;
1602
1653
  unmockPath(path: string): void;
1603
1654
  mockPath(path: string, external: string | null, factory?: () => any): void;
1604
1655
  importActual<T>(id: string, importer: string): Promise<T>;
@@ -1629,4 +1680,4 @@ declare class BaseSequencer implements TestSequencer {
1629
1680
  sort(files: string[]): Promise<string[]>;
1630
1681
  }
1631
1682
 
1632
- export { BaseSequencer, ExecuteOptions, TestSequencer, TestSequencerContructor, Vitest, VitestPlugin, VitestRunner, createVitest, startVitest };
1683
+ export { BaseSequencer, ExecuteOptions, TestSequencer, TestSequencerConstructor, Vitest, VitestPlugin, VitestRunner, createVitest, startVitest };
package/dist/node.mjs CHANGED
@@ -1,33 +1,31 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.0fc8ed68.mjs';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.34b9d585.mjs';
3
- import './chunk-env-node.aa51c4cc.mjs';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.a2813ad7.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.dfdfd57b.mjs';
3
+ import './chunk-utils-global.2aa95025.mjs';
4
+ import 'path';
5
+ import 'tty';
4
6
  import 'local-pkg';
7
+ import './chunk-defaults.408a0cfe.mjs';
5
8
  import 'fs';
6
9
  import 'module';
7
10
  import 'url';
8
- import './chunk-utils-global.4828c2e2.mjs';
9
- import 'tty';
10
- import 'path';
11
11
  import 'vite';
12
12
  import 'process';
13
- import './chunk-constants.27550afb.mjs';
14
- import 'readline';
13
+ import './chunk-constants.38b43a44.mjs';
15
14
  import 'os';
16
15
  import 'util';
17
16
  import 'stream';
18
17
  import 'events';
19
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
20
- import './chunk-vite-node-utils.0f776286.mjs';
19
+ import './chunk-vite-node-utils.ad73f2ab.mjs';
21
20
  import 'vm';
22
21
  import 'assert';
23
22
  import 'debug';
24
23
  import 'worker_threads';
25
24
  import 'tinypool';
26
25
  import 'perf_hooks';
27
- import './chunk-utils-source-map.a9047343.mjs';
28
- import './vendor-index.a2a385d8.mjs';
29
- import 'child_process';
30
- import 'buffer';
26
+ import './chunk-utils-source-map.8b066ce2.mjs';
31
27
  import 'crypto';
28
+ import './vendor-index.61438b77.mjs';
32
29
  import './chunk-magic-string.efe26975.mjs';
33
- import './vendor-index.98e769c1.mjs';
30
+ import 'readline';
31
+ import './vendor-index.de788b6a.mjs';
package/dist/spy.mjs CHANGED
@@ -1,2 +1,102 @@
1
- export { f as fn, i as isMockFunction, a as spies, s as spyOn } from './chunk-integrations-spy.674b628e.mjs';
2
- import 'tinyspy';
1
+ import * as tinyspy from 'tinyspy';
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[stub.calls.length - 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 };
package/dist/suite.mjs ADDED
@@ -0,0 +1,13 @@
1
+ import 'util';
2
+ import './chunk-utils-global.2aa95025.mjs';
3
+ export { e as clearCollectorContext, o as createSuiteHooks, f as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.1e1aabb3.mjs';
4
+ import 'path';
5
+ import 'tty';
6
+ import 'local-pkg';
7
+ import 'chai';
8
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
9
+ import './chunk-runtime-rpc.45d8ee19.mjs';
10
+ import 'fs';
11
+ import './chunk-utils-source-map.8b066ce2.mjs';
12
+ import './spy.mjs';
13
+ import 'tinyspy';