index.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. /// <reference types="yargs" />
  8. import { Config } from '@jest/types';
  9. import { JestEnvironment } from '@jest/environment';
  10. import { SourceMapRegistry } from '@jest/source-map';
  11. import HasteMap, { ModuleMap } from 'jest-haste-map';
  12. import Resolver from 'jest-resolve';
  13. import { ScriptTransformer, ShouldInstrumentOptions } from '@jest/transform';
  14. import { Context as JestContext } from './types';
  15. declare type HasteMapOptions = {
  16. console?: Console;
  17. maxWorkers: number;
  18. resetCache: boolean;
  19. watch?: boolean;
  20. watchman: boolean;
  21. };
  22. declare type InternalModuleOptions = {
  23. isInternalModule: boolean;
  24. };
  25. declare type CacheFS = {
  26. [path: string]: string;
  27. };
  28. declare namespace Runtime {
  29. type Context = JestContext;
  30. }
  31. declare class Runtime {
  32. static ScriptTransformer: typeof ScriptTransformer;
  33. private _cacheFS;
  34. private _config;
  35. private _coverageOptions;
  36. private _currentlyExecutingModulePath;
  37. private _environment;
  38. private _explicitShouldMock;
  39. private _internalModuleRegistry;
  40. private _isCurrentlyExecutingManualMock;
  41. private _mockFactories;
  42. private _mockMetaDataCache;
  43. private _mockRegistry;
  44. private _isolatedMockRegistry;
  45. private _moduleMocker;
  46. private _isolatedModuleRegistry;
  47. private _moduleRegistry;
  48. private _needsCoverageMapped;
  49. private _resolver;
  50. private _shouldAutoMock;
  51. private _shouldMockModuleCache;
  52. private _shouldUnmockTransitiveDependenciesCache;
  53. private _sourceMapRegistry;
  54. private _scriptTransformer;
  55. private _transitiveShouldMock;
  56. private _unmockList;
  57. private _virtualMocks;
  58. constructor(config: Config.ProjectConfig, environment: JestEnvironment, resolver: Resolver, cacheFS?: CacheFS, coverageOptions?: ShouldInstrumentOptions);
  59. static shouldInstrument(filename: Config.Path, options: ShouldInstrumentOptions, config: Config.ProjectConfig): boolean;
  60. static createContext(config: Config.ProjectConfig, options: {
  61. console?: Console;
  62. maxWorkers: number;
  63. watch?: boolean;
  64. watchman: boolean;
  65. }): Promise<JestContext>;
  66. static createHasteMap(config: Config.ProjectConfig, options?: HasteMapOptions): HasteMap;
  67. static createResolver(config: Config.ProjectConfig, moduleMap: ModuleMap): Resolver;
  68. static runCLI(args?: Config.Argv, info?: Array<string>): void;
  69. static getCLIOptions(): Record<"cache" | "config" | "debug" | "version" | "watchman", import("yargs").Options>;
  70. requireModule(from: Config.Path, moduleName?: string, options?: InternalModuleOptions, isRequireActual?: boolean | null): any;
  71. requireInternalModule(from: Config.Path, to?: string): any;
  72. requireActual(from: Config.Path, moduleName: string): any;
  73. requireMock(from: Config.Path, moduleName: string): any;
  74. private _loadModule;
  75. private _getFullTransformationOptions;
  76. requireModuleOrMock(from: Config.Path, moduleName: string): any;
  77. isolateModules(fn: () => void): void;
  78. resetModules(): void;
  79. getAllCoverageInfoCopy(): import("istanbul-lib-coverage").CoverageMapData;
  80. getSourceMapInfo(coveredFiles: Set<string>): {
  81. [path: string]: string;
  82. };
  83. getSourceMaps(): SourceMapRegistry;
  84. setMock(from: string, moduleName: string, mockFactory: () => unknown, options?: {
  85. virtual?: boolean;
  86. }): void;
  87. restoreAllMocks(): void;
  88. resetAllMocks(): void;
  89. clearAllMocks(): void;
  90. private _resolveModule;
  91. private _requireResolve;
  92. private _requireResolvePaths;
  93. private _execModule;
  94. private _requireCoreModule;
  95. private _generateMock;
  96. private _shouldMock;
  97. private _createRequireImplementation;
  98. private _createJestObjectFor;
  99. private _logFormattedReferenceError;
  100. }
  101. export = Runtime;
  102. //# sourceMappingURL=index.d.ts.map