vitest 0.15.1 → 0.17.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.
@@ -8727,7 +8727,7 @@ function moduleResolve(specifier, base, conditions) {
8727
8727
  const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
8728
8728
  const DEFAULT_URL = pathToFileURL(process.cwd());
8729
8729
  const DEFAULT_EXTENSIONS = [".mjs", ".cjs", ".js", ".json"];
8730
- const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set(["ERR_MODULE_NOT_FOUND", "ERR_UNSUPPORTED_DIR_IMPORT", "MODULE_NOT_FOUND"]);
8730
+ const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set(["ERR_MODULE_NOT_FOUND", "ERR_UNSUPPORTED_DIR_IMPORT", "MODULE_NOT_FOUND", "ERR_PACKAGE_PATH_NOT_EXPORTED"]);
8731
8731
  function _tryModuleResolve(id, url, conditions) {
8732
8732
  try {
8733
8733
  return moduleResolve(id, url, conditions);
@@ -8851,7 +8851,7 @@ function mergeSlashes(str) {
8851
8851
  function normalizeRequestId(id, base) {
8852
8852
  if (base && id.startsWith(base))
8853
8853
  id = `/${id.slice(base.length)}`;
8854
- return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?+$/, "");
8854
+ return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
8855
8855
  }
8856
8856
  function normalizeModuleId(id) {
8857
8857
  return id.replace(/\\/g, "/").replace(/^\/@fs\//, "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
@@ -8860,7 +8860,7 @@ function isPrimitive(v) {
8860
8860
  return v !== Object(v);
8861
8861
  }
8862
8862
  function toFilePath(id, root) {
8863
- let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname$2(root)) && dirname$2(root) !== "/" ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
8863
+ let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
8864
8864
  if (absolute.startsWith("//"))
8865
8865
  absolute = absolute.slice(1);
8866
8866
  return isWindows && absolute.startsWith("/") ? fileURLToPath$2(pathToFileURL(absolute.slice(1)).href) : absolute;
@@ -9007,6 +9007,7 @@ ${getStack()}`), 2e3);
9007
9007
  if (transformed == null)
9008
9008
  throw new Error(`[vite-node] Failed to load ${id}`);
9009
9009
  const url = pathToFileURL(fsPath).href;
9010
+ const meta = { url };
9010
9011
  const exports = /* @__PURE__ */ Object.create(null);
9011
9012
  exports[Symbol.toStringTag] = "Module";
9012
9013
  this.moduleCache.set(id, { code: transformed, exports });
@@ -9020,12 +9021,23 @@ ${getStack()}`), 2e3);
9020
9021
  return exports;
9021
9022
  }
9022
9023
  };
9024
+ let hotContext;
9025
+ if (this.options.createHotContext) {
9026
+ Object.defineProperty(meta, "hot", {
9027
+ enumerable: true,
9028
+ get: () => {
9029
+ var _a, _b;
9030
+ hotContext || (hotContext = (_b = (_a = this.options).createHotContext) == null ? void 0 : _b.call(_a, this, `/@fs/${fsPath}`));
9031
+ return hotContext;
9032
+ }
9033
+ });
9034
+ }
9023
9035
  const context = this.prepareContext({
9024
9036
  __vite_ssr_import__: request,
9025
9037
  __vite_ssr_dynamic_import__: request,
9026
9038
  __vite_ssr_exports__: exports,
9027
9039
  __vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
9028
- __vite_ssr_import_meta__: { url },
9040
+ __vite_ssr_import_meta__: meta,
9029
9041
  __vitest_resolve_id__: resolveId,
9030
9042
  require: createRequire(url),
9031
9043
  exports,
package/dist/cli.mjs CHANGED
@@ -1,30 +1,30 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { p as picocolors } from './chunk-utils-global.79a8b1cc.mjs';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.105bc106.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.1efbe319.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import 'vite';
8
- import 'url';
9
- import 'process';
7
+ import './chunk-env-node.dc514f41.mjs';
10
8
  import 'fs';
11
- import './chunk-defaults.dc6dc23d.mjs';
12
9
  import 'module';
13
- import './chunk-constants.7b9cfc82.mjs';
10
+ import 'url';
11
+ import 'vite';
12
+ import 'process';
13
+ import './chunk-constants.511c6e9b.mjs';
14
14
  import 'readline';
15
15
  import 'os';
16
16
  import 'util';
17
17
  import 'stream';
18
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
19
- import './chunk-vite-node-utils.c0a0e1b3.mjs';
19
+ import './chunk-vite-node-utils.4b58ae05.mjs';
20
20
  import 'vm';
21
21
  import 'assert';
22
22
  import 'debug';
23
23
  import 'worker_threads';
24
- import 'crypto';
25
24
  import 'tinypool';
25
+ import 'crypto';
26
26
  import 'perf_hooks';
27
- import './chunk-utils-source-map.2556cba8.mjs';
27
+ import './chunk-utils-source-map.f52527bc.mjs';
28
28
  import './vendor-index.e5dc6622.mjs';
29
29
  import 'child_process';
30
30
  import 'buffer';
package/dist/entry.mjs CHANGED
@@ -1,17 +1,17 @@
1
- export { r as run } from './vendor-entry.7ec02ea2.mjs';
1
+ export { r as run } from './vendor-entry.2edaf3e0.mjs';
2
2
  import 'fs';
3
3
  import './chunk-utils-global.79a8b1cc.mjs';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import './chunk-runtime-chain.ce7f4b92.mjs';
7
+ import './chunk-env-node.dc514f41.mjs';
8
+ import 'module';
9
+ import 'url';
10
+ import './chunk-runtime-chain.68f305d0.mjs';
8
11
  import 'chai';
9
12
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
10
13
  import './chunk-runtime-rpc.5e78af38.mjs';
11
- import './chunk-utils-source-map.2556cba8.mjs';
14
+ import './chunk-utils-source-map.f52527bc.mjs';
12
15
  import './chunk-integrations-spy.674b628e.mjs';
13
16
  import 'tinyspy';
14
17
  import 'util';
15
- import './chunk-defaults.dc6dc23d.mjs';
16
- import 'module';
17
- import 'url';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ViteDevServer, TransformResult, CommonServerOptions } from 'vite';
2
+ import { Stats } from 'fs';
2
3
  import { SpyImpl } from 'tinyspy';
3
4
  import { MessagePort } from 'worker_threads';
4
5
  export { assert, default as chai, should } from 'chai';
@@ -156,6 +157,87 @@ interface FakeTimerInstallOpts {
156
157
  shouldClearNativeTimers?: boolean | undefined;
157
158
  }
158
159
 
160
+ interface UpdatePayload {
161
+ type: 'update'
162
+ updates: Update[]
163
+ }
164
+
165
+ interface Update {
166
+ type: 'js-update' | 'css-update'
167
+ path: string
168
+ acceptedPath: string
169
+ timestamp: number
170
+ }
171
+
172
+ interface PrunePayload {
173
+ type: 'prune'
174
+ paths: string[]
175
+ }
176
+
177
+ interface FullReloadPayload {
178
+ type: 'full-reload'
179
+ path?: string
180
+ }
181
+
182
+ interface ErrorPayload {
183
+ type: 'error'
184
+ err: {
185
+ [name: string]: any
186
+ message: string
187
+ stack: string
188
+ id?: string
189
+ frame?: string
190
+ plugin?: string
191
+ pluginCode?: string
192
+ loc?: {
193
+ file?: string
194
+ line: number
195
+ column: number
196
+ }
197
+ }
198
+ }
199
+
200
+ interface CustomEventMap {
201
+ 'vite:beforeUpdate': UpdatePayload
202
+ 'vite:beforePrune': PrunePayload
203
+ 'vite:beforeFullReload': FullReloadPayload
204
+ 'vite:error': ErrorPayload
205
+ }
206
+
207
+ type InferCustomEventPayload<T extends string> =
208
+ T extends keyof CustomEventMap ? CustomEventMap[T] : any
209
+
210
+ type ModuleNamespace = Record<string, any> & {
211
+ [Symbol.toStringTag]: 'Module'
212
+ }
213
+
214
+ interface ViteHotContext {
215
+ readonly data: any
216
+
217
+ accept(): void
218
+ accept(cb: (mod: ModuleNamespace | undefined) => void): void
219
+ accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
220
+ accept(
221
+ deps: readonly string[],
222
+ cb: (mods: Array<ModuleNamespace | undefined>) => void
223
+ ): void
224
+
225
+ acceptExports(exportNames: string | readonly string[]): void
226
+ acceptExports(
227
+ exportNames: string | readonly string[],
228
+ cb: (mod: ModuleNamespace | undefined) => void
229
+ ): void
230
+
231
+ dispose(cb: (data: any) => void): void
232
+ decline(): void
233
+ invalidate(): void
234
+
235
+ on<T extends string>(
236
+ event: T,
237
+ cb: (payload: InferCustomEventPayload<T>) => void
238
+ ): void
239
+ send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
240
+ }
159
241
  declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
160
242
  normalizePath(fsPath: string): string;
161
243
  set(fsPath: string, mod: Partial<ModuleCache$1>): this;
@@ -217,8 +299,10 @@ interface FetchResult {
217
299
  externalize?: string;
218
300
  map?: RawSourceMap;
219
301
  }
302
+ declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
220
303
  declare type FetchFunction = (id: string) => Promise<FetchResult>;
221
304
  declare type ResolveIdFunction$1 = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
305
+ declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
222
306
  interface ModuleCache$1 {
223
307
  promise?: Promise<any>;
224
308
  exports?: any;
@@ -228,6 +312,7 @@ interface ViteNodeRunnerOptions {
228
312
  root: string;
229
313
  fetchModule: FetchFunction;
230
314
  resolveId?: ResolveIdFunction$1;
315
+ createHotContext?: CreateHotContextFunction;
231
316
  base?: string;
232
317
  moduleCache?: ModuleCacheMap;
233
318
  interopDefault?: boolean;
@@ -295,11 +380,42 @@ interface WorkerPool {
295
380
  close: () => Promise<void>;
296
381
  }
297
382
 
383
+ interface SuiteResultCache {
384
+ failed: boolean;
385
+ duration: number;
386
+ }
387
+ declare class ResultsCache {
388
+ private cache;
389
+ private cachePath;
390
+ private version;
391
+ private root;
392
+ setConfig(root: string, config: ResolvedConfig['cache']): void;
393
+ getResults(fsPath: string): SuiteResultCache | undefined;
394
+ readFromCache(): Promise<void>;
395
+ updateResults(files: File[]): void;
396
+ removeFromCache(filepath: string): void;
397
+ writeToCache(): Promise<void>;
398
+ }
399
+
400
+ declare type FileStatsCache = Pick<Stats, 'size'>;
401
+ declare class FilesStatsCache {
402
+ cache: Map<string, FileStatsCache>;
403
+ getStats(fsPath: string): FileStatsCache | undefined;
404
+ updateStats(fsPath: string): Promise<void>;
405
+ removeStats(fsPath: string): void;
406
+ }
407
+
298
408
  declare class StateManager {
299
409
  filesMap: Map<string, File>;
300
410
  idMap: Map<string, Task>;
301
411
  taskFileMap: WeakMap<Task, File>;
302
412
  errorsSet: Set<unknown>;
413
+ results: ResultsCache;
414
+ stats: FilesStatsCache;
415
+ getFileTestResults(id: string): SuiteResultCache | undefined;
416
+ getFileStats(id: string): {
417
+ size: number;
418
+ } | undefined;
303
419
  catchError(err: unknown, type: string): void;
304
420
  clearErrors(): void;
305
421
  getUnhandledErrors(): unknown[];
@@ -342,7 +458,7 @@ declare class Vitest {
342
458
  start(filters?: string[]): Promise<void>;
343
459
  private getTestDependencies;
344
460
  filterTestsBySource(tests: string[]): Promise<string[]>;
345
- runFiles(files: string[]): Promise<void>;
461
+ runFiles(paths: string[]): Promise<void>;
346
462
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
347
463
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
348
464
  rerunFailed(): Promise<void>;
@@ -496,7 +612,7 @@ declare type DeepMerge<F, S> = MergeInsertions<{
496
612
  declare type MutableArray<T extends readonly any[]> = {
497
613
  -readonly [k in keyof T]: T[k];
498
614
  };
499
- interface Constructable {
615
+ interface Constructable$1 {
500
616
  new (...args: any[]): any;
501
617
  }
502
618
  interface ModuleCache {
@@ -768,14 +884,14 @@ declare type SuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'onl
768
884
  skipIf(condition: any): SuiteAPI<ExtraContext>;
769
885
  runIf(condition: any): SuiteAPI<ExtraContext>;
770
886
  };
771
- declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
887
+ declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
888
+ declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
772
889
  interface SuiteHooks {
773
- beforeAll: HookListener<[Suite | File], () => Awaitable<void>>[];
890
+ beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
774
891
  afterAll: HookListener<[Suite | File]>[];
775
- beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
892
+ beforeEach: HookListener<[TestContext, Suite], HookCleanupCallback>[];
776
893
  afterEach: HookListener<[TestContext, Suite]>[];
777
894
  }
778
- declare type HookCleanupCallback = (() => Awaitable<void>) | void;
779
895
  interface SuiteCollector<ExtraContext = {}> {
780
896
  readonly name: string;
781
897
  readonly mode: RunMode;
@@ -865,7 +981,7 @@ interface SnapshotSummary {
865
981
  updated: number;
866
982
  }
867
983
 
868
- declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
984
+ declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
869
985
  declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
870
986
 
871
987
  interface EnvironmentOptions {
@@ -943,7 +1059,7 @@ interface InlineConfig {
943
1059
  /**
944
1060
  * Running environment
945
1061
  *
946
- * Supports 'node', 'jsdom', 'happy-dom'
1062
+ * Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
947
1063
  *
948
1064
  * @default 'node'
949
1065
  */
@@ -1168,6 +1284,13 @@ interface InlineConfig {
1168
1284
  * @default 5
1169
1285
  */
1170
1286
  maxConcurrency?: number;
1287
+ /**
1288
+ * Options for configuring cache policy.
1289
+ * @default { dir: 'node_modules/.vitest' }
1290
+ */
1291
+ cache?: false | {
1292
+ dir?: string;
1293
+ };
1171
1294
  }
1172
1295
  interface UserConfig extends InlineConfig {
1173
1296
  /**
@@ -1207,7 +1330,7 @@ interface UserConfig extends InlineConfig {
1207
1330
  */
1208
1331
  shard?: string;
1209
1332
  }
1210
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard'> {
1333
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard' | 'cache'> {
1211
1334
  base?: string;
1212
1335
  config?: string;
1213
1336
  filters?: string[];
@@ -1222,6 +1345,9 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
1222
1345
  index: number;
1223
1346
  count: number;
1224
1347
  };
1348
+ cache: {
1349
+ dir: string;
1350
+ } | false;
1225
1351
  }
1226
1352
 
1227
1353
  declare type VitestInlineConfig = InlineConfig;
@@ -1339,7 +1465,7 @@ declare class SnapshotState {
1339
1465
  updated: number;
1340
1466
  constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
1341
1467
  markSnapshotsAsCheckedForTest(testName: string): void;
1342
- private _getInlineSnapshotStack;
1468
+ private _inferInlineSnapshotStack;
1343
1469
  private _addSnapshot;
1344
1470
  clear(): void;
1345
1471
  save(): Promise<SaveStatus>;
@@ -1460,8 +1586,8 @@ declare global {
1460
1586
  nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
1461
1587
  toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
1462
1588
  lastCalledWith<E extends any[]>(...args: E): void;
1463
- toThrow(expected?: string | Constructable | RegExp | Error): void;
1464
- toThrowError(expected?: string | Constructable | RegExp | Error): void;
1589
+ toThrow(expected?: string | Constructable$1 | RegExp | Error): void;
1590
+ toThrowError(expected?: string | Constructable$1 | RegExp | Error): void;
1465
1591
  toReturn(): void;
1466
1592
  toHaveReturned(): void;
1467
1593
  toReturnTimes(times: number): void;
@@ -1499,7 +1625,6 @@ declare type BirpcReturn<RemoteFunctions> = {
1499
1625
 
1500
1626
  interface WorkerContext {
1501
1627
  workerId: number;
1502
- poolId: number;
1503
1628
  port: MessagePort;
1504
1629
  config: ResolvedConfig;
1505
1630
  files: string[];
@@ -1542,7 +1667,7 @@ interface MockResultThrow {
1542
1667
  value: any;
1543
1668
  }
1544
1669
  declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
1545
- interface SpyContext<TArgs, TReturns> {
1670
+ interface MockContext<TArgs, TReturns> {
1546
1671
  calls: TArgs[];
1547
1672
  instances: TReturns[];
1548
1673
  invocationCallOrder: number[];
@@ -1560,10 +1685,9 @@ declare type Classes<T> = {
1560
1685
  [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
1561
1686
  }[keyof T] & (string | symbol);
1562
1687
  interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
1563
- (...args: TArgs): TReturns;
1564
1688
  getMockName(): string;
1565
1689
  mockName(n: string): this;
1566
- mock: SpyContext<TArgs, TReturns>;
1690
+ mock: MockContext<TArgs, TReturns>;
1567
1691
  mockClear(): this;
1568
1692
  mockReset(): this;
1569
1693
  mockRestore(): void;
@@ -1578,15 +1702,17 @@ interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
1578
1702
  mockRejectedValue(obj: any): this;
1579
1703
  mockRejectedValueOnce(obj: any): this;
1580
1704
  }
1581
- interface SpyInstanceFn<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns> {
1582
- (...args: TArgs): TReturns;
1705
+ interface MockInstance<A extends any[] = any[], R = any> extends SpyInstance<A, R> {
1706
+ }
1707
+ interface Mock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns> {
1583
1708
  new (...args: TArgs): TReturns;
1709
+ (...args: TArgs): TReturns;
1584
1710
  }
1585
- declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? SpyInstanceFn<ConstructorParameters<T>, R> : T;
1586
- declare type MockedFunction<T extends Procedure> = MockWithArgs<T> & {
1711
+ declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? Mock<ConstructorParameters<T>, R> : T;
1712
+ declare type MockedFunction<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & {
1587
1713
  [K in keyof T]: T[K];
1588
1714
  };
1589
- declare type MockedFunctionDeep<T extends Procedure> = MockWithArgs<T> & MockedObjectDeep<T>;
1715
+ declare type MockedFunctionDeep<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
1590
1716
  declare type MockedObject<T> = MaybeMockedConstructor<T> & {
1591
1717
  [K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
1592
1718
  } & {
@@ -1599,16 +1725,23 @@ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
1599
1725
  };
1600
1726
  declare type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
1601
1727
  declare type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
1602
- declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
1603
- interface MockWithArgs<T extends Procedure> extends SpyInstanceFn<Parameters<T>, ReturnType<T>> {
1604
- new (...args: T extends new (...args: any) => any ? ConstructorParameters<T> : never): T;
1605
- (...args: Parameters<T>): ReturnType<T>;
1728
+ interface Constructable {
1729
+ new (...args: any[]): any;
1606
1730
  }
1731
+ declare type MockedClass<T extends Constructable> = MockInstance<InstanceType<T>, T extends new (...args: infer P) => any ? P : never> & {
1732
+ prototype: T extends {
1733
+ prototype: any;
1734
+ } ? Mocked<T['prototype']> : never;
1735
+ } & T;
1736
+ declare type Mocked<T> = {
1737
+ [P in keyof T]: T[P] extends (...args: infer Args) => infer Returns ? MockInstance<Args, Returns> : T[P] extends Constructable ? MockedClass<T[P]> : T[P];
1738
+ } & T;
1739
+ declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
1607
1740
  declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
1608
1741
  declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
1609
1742
  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;
1610
- declare function fn<TArgs extends any[] = any[], R = any>(): SpyInstanceFn<TArgs, R>;
1611
- declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): SpyInstanceFn<TArgs, R>;
1743
+ declare function fn<TArgs extends any[] = any[], R = any>(): Mock<TArgs, R>;
1744
+ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<TArgs, R>;
1612
1745
 
1613
1746
  declare const suite: SuiteAPI<{}>;
1614
1747
  declare const test: TestAPI<{}>;
@@ -1765,4 +1898,4 @@ interface WebSocketHandlers {
1765
1898
  interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog'> {
1766
1899
  }
1767
1900
 
1768
- 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, globalExpect as expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
1901
+ export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable$1 as Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyInstance, 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, globalExpect as expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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.ce7f4b92.mjs';
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.68f305d0.mjs';
2
2
  export { assert, default as chai, should } from 'chai';
3
3
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
4
4
  import './chunk-runtime-rpc.5e78af38.mjs';
@@ -7,7 +7,7 @@ import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
9
9
  import 'fs';
10
- import './chunk-utils-source-map.2556cba8.mjs';
10
+ import './chunk-utils-source-map.f52527bc.mjs';
11
11
  import './chunk-integrations-spy.674b628e.mjs';
12
12
  import 'tinyspy';
13
13
  import 'util';