node.d.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { c as VitestRunMode, U as UserConfig, t as Vitest, am as ModuleCacheMap, an as ViteNodeRunnerOptions, ao as MockMap, ap as ViteNodeRunner, aq as TestSequencer } from './global-e98f203b.js';
  2. export { aq as TestSequencer, as as TestSequencerConstructor, t as Vitest, ar as startVitest } from './global-e98f203b.js';
  3. import { UserConfig as UserConfig$1, Plugin } from 'vite';
  4. import 'tinybench';
  5. import 'fs';
  6. import 'worker_threads';
  7. declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
  8. declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
  9. declare type Key = string | symbol;
  10. interface ViteRunnerRequest {
  11. (dep: string): any;
  12. callstack: string[];
  13. }
  14. declare class VitestMocker {
  15. options: ExecuteOptions;
  16. private moduleCache;
  17. private request;
  18. private static pendingIds;
  19. private static spyModule?;
  20. constructor(options: ExecuteOptions, moduleCache: ModuleCacheMap, request: ViteRunnerRequest);
  21. private get root();
  22. private get base();
  23. private get mockMap();
  24. getSuiteFilepath(): string;
  25. getMocks(): {
  26. [x: string]: string | (() => unknown) | null;
  27. };
  28. private resolvePath;
  29. private resolveMocks;
  30. private callFunctionMock;
  31. private getMockPath;
  32. getDependencyMock(id: string): string | (() => unknown) | null;
  33. normalizePath(path: string): string;
  34. getFsPath(path: string, external: string | null): string;
  35. resolveMockPath(mockPath: string, external: string | null): string | null;
  36. mockObject(object: Record<string | symbol, any>): Record<Key, any>;
  37. unmockPath(path: string): void;
  38. mockPath(path: string, external: string | null, factory?: () => any): void;
  39. importActual<T>(id: string, importer: string): Promise<T>;
  40. importMock(id: string, importer: string): Promise<any>;
  41. private ensureSpy;
  42. requestWithMock(dep: string): Promise<any>;
  43. queueMock(id: string, importer: string, factory?: () => unknown): void;
  44. queueUnmock(id: string, importer: string): void;
  45. }
  46. interface ExecuteOptions extends ViteNodeRunnerOptions {
  47. mockMap: MockMap;
  48. }
  49. declare class VitestRunner extends ViteNodeRunner {
  50. options: ExecuteOptions;
  51. constructor(options: ExecuteOptions);
  52. prepareContext(context: Record<string, any>): Record<string, any> & {
  53. __vite_ssr_import__: (dep: string) => Promise<any>;
  54. __vite_ssr_dynamic_import__: (dep: string) => Promise<any>;
  55. __vitest_mocker__: VitestMocker;
  56. };
  57. }
  58. declare class BaseSequencer implements TestSequencer {
  59. protected ctx: Vitest;
  60. constructor(ctx: Vitest);
  61. shard(files: string[]): Promise<string[]>;
  62. sort(files: string[]): Promise<string[]>;
  63. }
  64. export { BaseSequencer, ExecuteOptions, VitestPlugin, VitestRunner, createVitest };