vitest 0.26.3 → 0.27.1

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 (44) hide show
  1. package/LICENSE.md +15 -66
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +15 -15
  4. package/dist/{chunk-api-setup.47a09f0f.js → chunk-api-setup.2be3cc38.js} +60 -31
  5. package/dist/{chunk-install-pkg.6dd2bae6.js → chunk-install-pkg.7b006b3e.js} +8 -8
  6. package/dist/{chunk-integrations-coverage.befed097.js → chunk-integrations-coverage.44413252.js} +19 -1
  7. package/dist/chunk-integrations-globals.02f1259c.js +27 -0
  8. package/dist/{chunk-typecheck-constants.06e1fe5b.js → chunk-mock-date.149ed990.js} +19 -32
  9. package/dist/{chunk-node-git.a90c0582.js → chunk-node-git.125c9008.js} +3 -4
  10. package/dist/{chunk-runtime-chain.f51aa930.js → chunk-runtime-chain.4e2aa823.js} +1193 -1029
  11. package/dist/{chunk-runtime-error.f5c8aaf2.js → chunk-runtime-error.97854396.js} +2 -2
  12. package/dist/{chunk-runtime-mocker.887bf8c8.js → chunk-runtime-mocker.4755840f.js} +10 -8
  13. package/dist/{chunk-runtime-rpc.54d72169.js → chunk-runtime-rpc.25cc9413.js} +2 -2
  14. package/dist/{chunk-runtime-setup.a06d5c72.js → chunk-runtime-setup.56d71d30.js} +51 -52
  15. package/dist/{chunk-snapshot-manager.70695b70.js → chunk-snapshot-manager.1a2dbf96.js} +468 -302
  16. package/dist/{chunk-utils-env.3fdc1793.js → chunk-utils-env.f4a39d2c.js} +8 -70
  17. package/dist/{chunk-utils-import.e7f64637.js → chunk-utils-import.16d9fb0d.js} +22 -8
  18. package/dist/chunk-utils-source-map.4e9b891d.js +408 -0
  19. package/dist/{chunk-utils-timers.715da787.js → chunk-utils-timers.52534f96.js} +2977 -3458
  20. package/dist/cli-wrapper.js +15 -15
  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-761e769b.d.ts → index-1cfc7f58.d.ts} +4 -2
  28. package/dist/index.d.ts +4 -4
  29. package/dist/index.js +12 -12
  30. package/dist/loader.js +9 -10
  31. package/dist/node.d.ts +2 -2
  32. package/dist/node.js +14 -12
  33. package/dist/spy.js +2 -102
  34. package/dist/suite.js +10 -10
  35. package/dist/{types-bae746aa.d.ts → types-5617096e.d.ts} +97 -77
  36. package/dist/{vendor-index.b2fdde54.js → vendor-index.451e37bc.js} +1 -1
  37. package/dist/vendor-index.723a074f.js +102 -0
  38. package/dist/vendor-index.b0346fe4.js +395 -0
  39. package/dist/{vendor-index.7a2cebfe.js → vendor-index.e6c27006.js} +12 -12
  40. package/dist/worker.js +24 -19
  41. package/package.json +13 -8
  42. package/dist/chunk-integrations-globals.ee28730b.js +0 -27
  43. package/dist/chunk-utils-source-map.5278ee22.js +0 -86
  44. package/dist/vendor-index.2e96c50b.js +0 -215
package/dist/config.cjs CHANGED
@@ -19,10 +19,11 @@ const defaultCoverageExcludes = [
19
19
  "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
20
20
  ];
21
21
  const coverageConfigDefaults = {
22
+ all: false,
22
23
  provider: "c8",
23
24
  enabled: false,
24
25
  clean: true,
25
- cleanOnRerun: false,
26
+ cleanOnRerun: true,
26
27
  reportsDirectory: "./coverage",
27
28
  excludeNodeModules: true,
28
29
  exclude: defaultCoverageExcludes,
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-bae746aa.js';
3
+ import { U as UserConfig$1, an as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-5617096e.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.06e1fe5b.js';
3
- import { v as vi } from './chunk-utils-import.e7f64637.js';
2
+ import { g as getWorkerState, a as resetModules } from './chunk-mock-date.149ed990.js';
3
+ import { v as vi } from './chunk-utils-import.16d9fb0d.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.a06d5c72.js';
5
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.56d71d30.js';
6
6
  import 'node:path';
7
- import './chunk-utils-env.3fdc1793.js';
8
- import 'tty';
7
+ import 'picocolors';
8
+ import 'local-pkg';
9
+ import './chunk-utils-env.f4a39d2c.js';
9
10
  import 'node:url';
10
11
  import 'path';
11
- import 'local-pkg';
12
- import './chunk-runtime-chain.f51aa930.js';
12
+ import './chunk-runtime-chain.4e2aa823.js';
13
13
  import 'util';
14
14
  import 'chai';
15
15
  import './vendor-_commonjsHelpers.addc3445.js';
16
- import './chunk-runtime-rpc.54d72169.js';
17
- import './chunk-utils-timers.715da787.js';
18
- import './chunk-utils-source-map.5278ee22.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.4e9b891d.js';
20
+ import './chunk-runtime-rpc.25cc9413.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.f5c8aaf2.js';
24
+ import './chunk-integrations-coverage.44413252.js';
25
+ import './chunk-runtime-error.97854396.js';
26
26
  import 'vite-node/source-map';
27
27
 
28
28
  function groupBy(collection, iteratee) {
@@ -1,4 +1,4 @@
1
- import { af as Environment } from './types-bae746aa.js';
1
+ import { ae as Environment } from './types-5617096e.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 { x as SuiteAPI, w as TestAPI, aw as BenchmarkAPI, z as SuiteHooks, H as HookListener, N as TestContext, q as Suite, y as HookCleanupCallback, O as OnTestFailedHandler, r as Test } from './types-bae746aa.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-5617096e.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;
@@ -234,7 +234,9 @@ type Mocked<T> = {
234
234
  type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
235
235
  declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
236
236
  declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
237
- declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends (...args: infer A) => infer R | (new (...args: infer A) => infer R) ? SpyInstance<A, R> : never;
237
+ declare function spyOn<T, M extends (Classes<Required<T>> | Methods<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends ({
238
+ new (...args: infer A): infer R;
239
+ }) | ((...args: infer A) => infer R) ? SpyInstance<A, R> : never;
238
240
  declare function fn<TArgs extends any[] = any[], R = any>(): Mock<TArgs, R>;
239
241
  declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<TArgs, R>;
240
242
 
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-761e769b.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-761e769b.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-bae746aa.js';
4
- export { a2 as AfterSuiteRunMeta, A as ApiConfig, a8 as ArgumentsType, a7 as Arrayable, a5 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, j as CSSModuleScopeStrategy, C as CollectLineNumbers, g as CollectLines, ac as Constructable, i as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, aa as DeepMerge, D as DoneCallback, af as Environment, E as EnvironmentOptions, ae as EnvironmentReturn, ai as ErrorWithDiff, a as File, y as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a9 as MergeInsertions, ad as ModuleCache, c as ModuleGraphData, ab as MutableArray, a6 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, e as RawErrsMap, d as Reporter, a1 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, h as RootAndTarget, m as RunMode, R as RuntimeConfig, L as RuntimeContext, S as SequenceHooks, Q as SnapshotData, Y as SnapshotMatchOptions, Z as SnapshotResult, X as SnapshotStateOptions, $ as SnapshotSummary, W as SnapshotUpdateState, q as Suite, x as SuiteAPI, G as SuiteCollector, K as SuiteFactory, z as SuiteHooks, t as Task, o as TaskBase, p as TaskResult, T as TaskResultPack, n as TaskState, r as Test, w as TestAPI, N as TestContext, u as TestFunction, v as TestOptions, f as TscErrorInfo, s as TypeCheck, l as TypecheckConfig, _ as UncheckedSnapshot, U as UserConfig, ag as UserConsoleLog, P as Vitest, V as VitestEnvironment, k as VitestRunMode, a0 as WorkerContext, a4 as WorkerGlobalState, a3 as WorkerRPC } from './types-bae746aa.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-1cfc7f58.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-1cfc7f58.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-5617096e.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-5617096e.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
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.f51aa930.js';
2
- import { e as dist } from './chunk-utils-import.e7f64637.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.e7f64637.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.4e2aa823.js';
2
+ import { e as dist } from './chunk-utils-import.16d9fb0d.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.16d9fb0d.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.06e1fe5b.js';
8
+ import './chunk-mock-date.149ed990.js';
9
9
  import 'node:path';
10
- import './chunk-utils-env.3fdc1793.js';
11
- import 'tty';
10
+ import 'picocolors';
11
+ import 'local-pkg';
12
+ import './chunk-utils-env.f4a39d2c.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.54d72169.js';
17
- import './chunk-utils-timers.715da787.js';
16
+ import './chunk-utils-timers.52534f96.js';
17
+ import './vendor-index.723a074f.js';
18
+ import 'tinyspy';
19
+ import './chunk-utils-source-map.4e9b891d.js';
20
+ import './chunk-runtime-rpc.25cc9413.js';
18
21
  import 'node:fs';
19
- import './chunk-utils-source-map.5278ee22.js';
20
22
  import 'fs';
21
- import './spy.js';
22
- import 'tinyspy';
23
23
 
24
24
 
25
25
 
package/dist/loader.js CHANGED
@@ -1,21 +1,20 @@
1
1
  import { pathToFileURL } from 'node:url';
2
2
  import { readFile } from 'node:fs/promises';
3
- import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.2e96c50b.js';
3
+ import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.b0346fe4.js';
4
4
  import { normalizeModuleId } from 'vite-node/utils';
5
- import { g as getWorkerState } from './chunk-typecheck-constants.06e1fe5b.js';
5
+ import { g as getWorkerState } from './chunk-mock-date.149ed990.js';
6
6
  import 'acorn';
7
7
  import 'node:module';
8
8
  import 'node:fs';
9
- import 'url';
10
- import 'fs';
11
- import 'path';
12
- import 'module';
13
- import 'assert';
14
- import 'util';
9
+ import 'node:assert';
10
+ import 'node:process';
15
11
  import 'node:path';
16
- import './chunk-utils-env.3fdc1793.js';
17
- import 'tty';
12
+ import 'node:v8';
13
+ import 'node:util';
14
+ import 'picocolors';
18
15
  import 'local-pkg';
16
+ import './chunk-utils-env.f4a39d2c.js';
17
+ import 'path';
19
18
 
20
19
  var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
21
20
  ModuleFormat2["Builtin"] = "builtin";
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { k as VitestRunMode, U as UserConfig, P as Vitest, ax as MockFactory, ay as MockMap, az as TestSequencer } from './types-bae746aa.js';
2
- export { az as TestSequencer, aB as TestSequencerConstructor, P as Vitest, aA as startVitest } from './types-bae746aa.js';
1
+ import { k as VitestRunMode, U as UserConfig, N as Vitest, aw as MockFactory, ax as MockMap, ay as TestSequencer } from './types-5617096e.js';
2
+ export { ay as TestSequencer, aA as TestSequencerConstructor, N as Vitest, az as startVitest } from './types-5617096e.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';
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.70695b70.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.887bf8c8.js';
3
- import './chunk-utils-env.3fdc1793.js';
4
- import 'tty';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-snapshot-manager.1a2dbf96.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.4755840f.js';
3
+ import './chunk-utils-env.f4a39d2c.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.06e1fe5b.js';
10
+ import './chunk-mock-date.149ed990.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.b2fdde54.js';
25
+ import './vendor-index.451e37bc.js';
26
26
  import 'node:buffer';
27
27
  import 'node:child_process';
28
- import './vendor-index.7a2cebfe.js';
28
+ import './vendor-index.e6c27006.js';
29
29
  import 'child_process';
30
30
  import 'assert';
31
31
  import 'buffer';
@@ -38,8 +38,8 @@ 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.715da787.js';
42
- import './chunk-utils-source-map.5278ee22.js';
41
+ import './chunk-utils-source-map.4e9b891d.js';
42
+ import './chunk-utils-timers.52534f96.js';
43
43
  import 'crypto';
44
44
  import 'vite-node/utils';
45
45
  import './vendor-index.9c919048.js';
@@ -48,6 +48,8 @@ import './chunk-magic-string.3a794426.js';
48
48
  import 'strip-literal';
49
49
  import 'readline';
50
50
  import './vendor-index.9f20a9be.js';
51
- import './vendor-index.2e96c50b.js';
51
+ import './vendor-index.b0346fe4.js';
52
52
  import 'node:module';
53
- import 'url';
53
+ import 'node:assert';
54
+ import 'node:v8';
55
+ import 'node:util';
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.06e1fe5b.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.f51aa930.js';
3
+ import './chunk-mock-date.149ed990.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.4e2aa823.js';
5
5
  import 'node:path';
6
- import './chunk-utils-env.3fdc1793.js';
7
- import 'tty';
6
+ import 'picocolors';
7
+ import 'local-pkg';
8
+ import './chunk-utils-env.f4a39d2c.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.54d72169.js';
13
- import './chunk-utils-timers.715da787.js';
12
+ import './chunk-utils-timers.52534f96.js';
13
+ import './vendor-index.723a074f.js';
14
+ import 'tinyspy';
15
+ import './chunk-utils-source-map.4e9b891d.js';
16
+ import './chunk-runtime-rpc.25cc9413.js';
14
17
  import 'node:fs';
15
- import './chunk-utils-source-map.5278ee22.js';
16
18
  import 'fs';
17
- import './spy.js';
18
- import 'tinyspy';