vitest 0.26.2 → 0.27.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 (43) hide show
  1. package/LICENSE.md +2 -54
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +15 -15
  4. package/dist/{chunk-api-setup.46ee0021.js → chunk-api-setup.16ac28c0.js} +13 -3
  5. package/dist/{chunk-install-pkg.31846bc1.js → chunk-install-pkg.6dd2bae6.js} +2 -2
  6. package/dist/{chunk-integrations-coverage.befed097.js → chunk-integrations-coverage.44413252.js} +19 -1
  7. package/dist/chunk-integrations-globals.3dfaeb99.js +27 -0
  8. package/dist/{chunk-typecheck-constants.e478eb98.js → chunk-mock-date.a1c85759.js} +10 -28
  9. package/dist/{chunk-node-git.43b341db.js → chunk-node-git.543e964a.js} +3 -4
  10. package/dist/{chunk-runtime-chain.198631fd.js → chunk-runtime-chain.6df5a66b.js} +1192 -1028
  11. package/dist/{chunk-runtime-error.12631a44.js → chunk-runtime-error.fad2c32b.js} +2 -2
  12. package/dist/{chunk-runtime-mocker.03096876.js → chunk-runtime-mocker.a677dd28.js} +10 -8
  13. package/dist/{chunk-runtime-rpc.503623e9.js → chunk-runtime-rpc.7f83c8a9.js} +2 -2
  14. package/dist/{chunk-runtime-setup.f79addc3.js → chunk-runtime-setup.731b2b04.js} +51 -52
  15. package/dist/{chunk-snapshot-manager.8c94a052.js → chunk-snapshot-manager.700322bf.js} +430 -303
  16. package/dist/{chunk-utils-env.4afc6329.js → chunk-utils-env.b861e3a0.js} +1 -63
  17. package/dist/{chunk-utils-import.dc87c88c.js → chunk-utils-import.2baa69a9.js} +38 -13
  18. package/dist/chunk-utils-source-map.60562959.js +408 -0
  19. package/dist/{chunk-utils-timers.54caa12a.js → chunk-utils-timers.52534f96.js} +2977 -3458
  20. package/dist/cli-wrapper.js +13 -13
  21. package/dist/cli.js +15 -627
  22. package/dist/config.cjs +2 -1
  23. package/dist/config.d.ts +1 -1
  24. package/dist/config.js +2 -1
  25. package/dist/entry.js +14 -14
  26. package/dist/environments.d.ts +1 -1
  27. package/dist/{index-40ebba2b.d.ts → index-2d10c3fd.d.ts} +1 -1
  28. package/dist/index.d.ts +6 -6
  29. package/dist/index.js +12 -12
  30. package/dist/loader.js +3 -3
  31. package/dist/node.d.ts +6 -6
  32. package/dist/node.js +11 -11
  33. package/dist/spy.js +2 -102
  34. package/dist/suite.js +10 -10
  35. package/dist/{types-2a26f28c.d.ts → types-e1e1d1e5.d.ts} +92 -83
  36. package/dist/vendor-index.723a074f.js +102 -0
  37. package/dist/{vendor-index.62932580.js → vendor-index.7a2cebfe.js} +0 -0
  38. package/dist/{vendor-index.808a85a6.js → vendor-index.9c919048.js} +0 -0
  39. package/dist/{vendor-index.a323f2d0.js → vendor-index.b2fdde54.js} +1 -1
  40. package/dist/worker.js +7 -7
  41. package/package.json +9 -5
  42. package/dist/chunk-integrations-globals.5af12e76.js +0 -27
  43. package/dist/chunk-utils-source-map.95b8b3f0.js +0 -94
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv } from 'vite';
3
- import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-2a26f28c.js';
3
+ import { U as UserConfig$1, an as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-e1e1d1e5.js';
4
4
  import 'tinybench';
5
5
  import 'vite-node/client';
6
6
  import 'vite-node/server';
package/dist/config.js CHANGED
@@ -15,10 +15,11 @@ const defaultCoverageExcludes = [
15
15
  "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
16
16
  ];
17
17
  const coverageConfigDefaults = {
18
+ all: false,
18
19
  provider: "c8",
19
20
  enabled: false,
20
21
  clean: true,
21
- cleanOnRerun: false,
22
+ cleanOnRerun: true,
22
23
  reportsDirectory: "./coverage",
23
24
  excludeNodeModules: true,
24
25
  exclude: defaultCoverageExcludes,
package/dist/entry.js CHANGED
@@ -1,28 +1,28 @@
1
1
  import { promises } from 'node:fs';
2
- import { g as getWorkerState, a as resetModules } from './chunk-typecheck-constants.e478eb98.js';
3
- import { v as vi } from './chunk-utils-import.dc87c88c.js';
2
+ import { g as getWorkerState, a as resetModules } from './chunk-mock-date.a1c85759.js';
3
+ import { v as vi } from './chunk-utils-import.2baa69a9.js';
4
4
  import { a as envs } from './chunk-env-node.b3664da2.js';
5
- import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.f79addc3.js';
5
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.731b2b04.js';
6
6
  import 'node:path';
7
- import './chunk-utils-env.4afc6329.js';
8
- import 'tty';
7
+ import 'picocolors';
8
+ import 'local-pkg';
9
+ import './chunk-utils-env.b861e3a0.js';
9
10
  import 'node:url';
10
11
  import 'path';
11
- import 'local-pkg';
12
- import './chunk-runtime-chain.198631fd.js';
12
+ import './chunk-runtime-chain.6df5a66b.js';
13
13
  import 'util';
14
14
  import 'chai';
15
15
  import './vendor-_commonjsHelpers.addc3445.js';
16
- import './chunk-runtime-rpc.503623e9.js';
17
- import './chunk-utils-timers.54caa12a.js';
18
- import './chunk-utils-source-map.95b8b3f0.js';
19
- import 'fs';
20
- import './spy.js';
16
+ import './chunk-utils-timers.52534f96.js';
17
+ import './vendor-index.723a074f.js';
21
18
  import 'tinyspy';
19
+ import './chunk-utils-source-map.60562959.js';
20
+ import './chunk-runtime-rpc.7f83c8a9.js';
21
+ import 'fs';
22
22
  import 'node:console';
23
23
  import 'perf_hooks';
24
- import './chunk-integrations-coverage.befed097.js';
25
- import './chunk-runtime-error.12631a44.js';
24
+ import './chunk-integrations-coverage.44413252.js';
25
+ import './chunk-runtime-error.fad2c32b.js';
26
26
  import 'vite-node/source-map';
27
27
 
28
28
  function groupBy(collection, iteratee) {
@@ -1,4 +1,4 @@
1
- import { ae as Environment } from './types-2a26f28c.js';
1
+ import { ae as Environment } from './types-e1e1d1e5.js';
2
2
  import 'vite';
3
3
  import 'tinybench';
4
4
  import 'vite-node/client';
@@ -1,5 +1,5 @@
1
1
  import { SpyImpl } from 'tinyspy';
2
- import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-2a26f28c.js';
2
+ import { w as SuiteAPI, v as TestAPI, av as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, q as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, r as Test } from './types-e1e1d1e5.js';
3
3
 
4
4
  declare type Not<T extends boolean> = T extends true ? false : true;
5
5
  declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-40ebba2b.js';
2
- export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-40ebba2b.js';
3
- import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-2a26f28c.js';
4
- export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-2a26f28c.js';
1
+ import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-2d10c3fd.js';
2
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-2d10c3fd.js';
3
+ import { D as DoneCallback, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, c as ModuleGraphData, d as Reporter } from './types-e1e1d1e5.js';
4
+ export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ao as BaseCoverageOptions, au as BenchFunction, as as Benchmark, av as BenchmarkAPI, at as BenchmarkResult, ar as BenchmarkUserOptions, B as BuiltinEnvironment, j as CSSModuleScopeStrategy, C as CollectLineNumbers, g as CollectLines, ab as Constructable, i as Context, aq as CoverageC8Options, ap as CoverageIstanbulOptions, am as CoverageOptions, aj as CoverageProvider, ak as CoverageProviderModule, al as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ah as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, c as ModuleGraphData, aa as MutableArray, a5 as Nullable, ai as OnServerRestartHandler, O as OnTestFailedHandler, ag as ParsedStack, e as RawErrsMap, d as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, an as ResolvedCoverageOptions, h as RootAndTarget, m as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, q as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, o as TaskBase, p as TaskResult, T as TaskResultPack, n as TaskState, r as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, f as TscErrorInfo, l as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, k as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-e1e1d1e5.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
@@ -69,7 +69,7 @@ declare class VitestUtils {
69
69
  * @param path Path to the module. Can be aliased, if your config supports it
70
70
  * @param factory Factory for the mocked module. Has the highest priority.
71
71
  */
72
- mock(path: string, factory?: () => any): void;
72
+ mock(path: string, factory?: MockFactoryWithHelper): void;
73
73
  /**
74
74
  * Removes module from mocked registry. All subsequent calls to import will
75
75
  * return original module even if it was mocked.
@@ -90,7 +90,7 @@ declare class VitestUtils {
90
90
  * @param path Path to the module. Can be aliased, if your config supports it
91
91
  * @returns Actual module without spies
92
92
  */
93
- importActual<T>(path: string): Promise<T>;
93
+ importActual<T = unknown>(path: string): Promise<T>;
94
94
  /**
95
95
  * Imports a module with all of its properties and nested properties mocked.
96
96
  * For the rules applied, see docs.
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.198631fd.js';
2
- import { e as dist } from './chunk-utils-import.dc87c88c.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-utils-import.dc87c88c.js';
1
+ export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.6df5a66b.js';
2
+ import { e as dist } from './chunk-utils-import.2baa69a9.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-utils-import.2baa69a9.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
7
7
  import 'util';
8
- import './chunk-typecheck-constants.e478eb98.js';
8
+ import './chunk-mock-date.a1c85759.js';
9
9
  import 'node:path';
10
- import './chunk-utils-env.4afc6329.js';
11
- import 'tty';
10
+ import 'picocolors';
11
+ import 'local-pkg';
12
+ import './chunk-utils-env.b861e3a0.js';
12
13
  import 'node:url';
13
14
  import 'path';
14
- import 'local-pkg';
15
15
  import './vendor-_commonjsHelpers.addc3445.js';
16
- import './chunk-runtime-rpc.503623e9.js';
17
- import './chunk-utils-timers.54caa12a.js';
16
+ import './chunk-utils-timers.52534f96.js';
17
+ import './vendor-index.723a074f.js';
18
+ import 'tinyspy';
19
+ import './chunk-utils-source-map.60562959.js';
20
+ import './chunk-runtime-rpc.7f83c8a9.js';
18
21
  import 'node:fs';
19
- import './chunk-utils-source-map.95b8b3f0.js';
20
22
  import 'fs';
21
- import './spy.js';
22
- import 'tinyspy';
23
23
 
24
24
 
25
25
 
package/dist/loader.js CHANGED
@@ -2,7 +2,7 @@ import { pathToFileURL } from 'node:url';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.2e96c50b.js';
4
4
  import { normalizeModuleId } from 'vite-node/utils';
5
- import { g as getWorkerState } from './chunk-typecheck-constants.e478eb98.js';
5
+ import { g as getWorkerState } from './chunk-mock-date.a1c85759.js';
6
6
  import 'acorn';
7
7
  import 'node:module';
8
8
  import 'node:fs';
@@ -13,9 +13,9 @@ import 'module';
13
13
  import 'assert';
14
14
  import 'util';
15
15
  import 'node:path';
16
- import './chunk-utils-env.4afc6329.js';
17
- import 'tty';
16
+ import 'picocolors';
18
17
  import 'local-pkg';
18
+ import './chunk-utils-env.b861e3a0.js';
19
19
 
20
20
  var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
21
21
  ModuleFormat2["Builtin"] = "builtin";
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as MockMap, ay as TestSequencer } from './types-2a26f28c.js';
2
- export { ay as TestSequencer, aA as TestSequencerConstructor, N as Vitest, az as startVitest } from './types-2a26f28c.js';
1
+ import { k as VitestRunMode, U as UserConfig, N as Vitest, aw as MockFactory, ax as MockMap, ay as TestSequencer } from './types-e1e1d1e5.js';
2
+ export { ay as TestSequencer, aA as TestSequencerConstructor, N as Vitest, az as startVitest } from './types-e1e1d1e5.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import { ViteNodeRunner } from 'vite-node/client';
5
5
  import { ViteNodeRunnerOptions } from 'vite-node';
@@ -26,23 +26,23 @@ declare class VitestMocker {
26
26
  private get moduleCache();
27
27
  getSuiteFilepath(): string;
28
28
  getMocks(): {
29
- [x: string]: string | (() => unknown) | null;
29
+ [x: string]: string | MockFactory | null;
30
30
  };
31
31
  private resolvePath;
32
32
  private resolveMocks;
33
33
  private callFunctionMock;
34
34
  getMockPath(dep: string): string;
35
- getDependencyMock(id: string): string | (() => unknown) | null;
35
+ getDependencyMock(id: string): string | MockFactory | null;
36
36
  normalizePath(path: string): string;
37
37
  resolveMockPath(mockPath: string, external: string | null): string | null;
38
38
  mockObject(object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
39
39
  unmockPath(path: string): void;
40
- mockPath(originalId: string, path: string, external: string | null, factory?: () => any): void;
40
+ mockPath(originalId: string, path: string, external: string | null, factory?: MockFactory): void;
41
41
  importActual<T>(rawId: string, importee: string): Promise<T>;
42
42
  importMock(rawId: string, importee: string): Promise<any>;
43
43
  initializeSpyModule(): Promise<void>;
44
44
  requestWithMock(url: string, callstack: string[]): Promise<any>;
45
- queueMock(id: string, importer: string, factory?: () => unknown): void;
45
+ queueMock(id: string, importer: string, factory?: MockFactory): void;
46
46
  queueUnmock(id: string, importer: string): void;
47
47
  }
48
48
 
package/dist/node.js CHANGED
@@ -1,15 +1,15 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-snapshot-manager.8c94a052.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.03096876.js';
3
- import './chunk-utils-env.4afc6329.js';
4
- import 'tty';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-snapshot-manager.700322bf.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.a677dd28.js';
3
+ import './chunk-utils-env.b861e3a0.js';
5
4
  import 'node:url';
6
5
  import 'path';
7
- import './chunk-integrations-coverage.befed097.js';
6
+ import './chunk-integrations-coverage.44413252.js';
8
7
  import 'local-pkg';
9
8
  import './chunk-env-node.b3664da2.js';
10
9
  import 'node:console';
11
- import './chunk-typecheck-constants.e478eb98.js';
10
+ import './chunk-mock-date.a1c85759.js';
12
11
  import 'node:path';
12
+ import 'picocolors';
13
13
  import 'vite';
14
14
  import 'node:process';
15
15
  import 'node:fs';
@@ -22,10 +22,10 @@ import './vendor-_commonjsHelpers.addc3445.js';
22
22
  import 'vite-node/client';
23
23
  import 'vite-node/server';
24
24
  import 'node:fs/promises';
25
- import './vendor-index.a323f2d0.js';
25
+ import './vendor-index.b2fdde54.js';
26
26
  import 'node:buffer';
27
27
  import 'node:child_process';
28
- import './vendor-index.62932580.js';
28
+ import './vendor-index.7a2cebfe.js';
29
29
  import 'child_process';
30
30
  import 'assert';
31
31
  import 'buffer';
@@ -38,11 +38,11 @@ import 'node:worker_threads';
38
38
  import 'tinypool';
39
39
  import './vendor-index.783e7f3e.js';
40
40
  import 'perf_hooks';
41
- import './chunk-utils-timers.54caa12a.js';
42
- import './chunk-utils-source-map.95b8b3f0.js';
41
+ import './chunk-utils-source-map.60562959.js';
42
+ import './chunk-utils-timers.52534f96.js';
43
43
  import 'crypto';
44
44
  import 'vite-node/utils';
45
- import './vendor-index.808a85a6.js';
45
+ import './vendor-index.9c919048.js';
46
46
  import 'node:crypto';
47
47
  import './chunk-magic-string.3a794426.js';
48
48
  import 'strip-literal';
package/dist/spy.js CHANGED
@@ -1,102 +1,2 @@
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 };
1
+ export { f as fn, i as isMockFunction, a as spies, s as spyOn } from './vendor-index.723a074f.js';
2
+ import 'tinyspy';
package/dist/suite.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import 'util';
2
2
  import 'chai';
3
- import './chunk-typecheck-constants.e478eb98.js';
4
- export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.198631fd.js';
3
+ import './chunk-mock-date.a1c85759.js';
4
+ export { b as bench, f as clearCollectorContext, r as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.6df5a66b.js';
5
5
  import 'node:path';
6
- import './chunk-utils-env.4afc6329.js';
7
- import 'tty';
6
+ import 'picocolors';
7
+ import 'local-pkg';
8
+ import './chunk-utils-env.b861e3a0.js';
8
9
  import 'node:url';
9
10
  import 'path';
10
- import 'local-pkg';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
- import './chunk-runtime-rpc.503623e9.js';
13
- import './chunk-utils-timers.54caa12a.js';
12
+ import './chunk-utils-timers.52534f96.js';
13
+ import './vendor-index.723a074f.js';
14
+ import 'tinyspy';
15
+ import './chunk-utils-source-map.60562959.js';
16
+ import './chunk-runtime-rpc.7f83c8a9.js';
14
17
  import 'node:fs';
15
- import './chunk-utils-source-map.95b8b3f0.js';
16
18
  import 'fs';
17
- import './spy.js';
18
- import 'tinyspy';