index.d.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  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. import type {Config} from '@jest/types';
  8. import type {DeprecatedOptions} from 'jest-validate';
  9. declare type AllOptions = Config.ProjectConfig & Config.GlobalConfig;
  10. declare namespace constants {
  11. export {
  12. NODE_MODULES,
  13. DEFAULT_JS_PATTERN,
  14. PACKAGE_JSON,
  15. JEST_CONFIG_BASE_NAME,
  16. JEST_CONFIG_EXT_CJS,
  17. JEST_CONFIG_EXT_MJS,
  18. JEST_CONFIG_EXT_JS,
  19. JEST_CONFIG_EXT_TS,
  20. JEST_CONFIG_EXT_JSON,
  21. JEST_CONFIG_EXT_ORDER,
  22. };
  23. }
  24. export {constants};
  25. declare const DEFAULT_JS_PATTERN = '\\.[jt]sx?$';
  26. export declare const defaults: Config.DefaultOptions;
  27. export declare const deprecationEntries: DeprecatedOptions;
  28. export declare const descriptions: {
  29. [key in keyof Config.InitialOptions]: string;
  30. };
  31. export declare const isJSONString: (
  32. text?: JSONString | string,
  33. ) => text is JSONString;
  34. declare const JEST_CONFIG_BASE_NAME = 'jest.config';
  35. declare const JEST_CONFIG_EXT_CJS = '.cjs';
  36. declare const JEST_CONFIG_EXT_JS = '.js';
  37. declare const JEST_CONFIG_EXT_JSON = '.json';
  38. declare const JEST_CONFIG_EXT_MJS = '.mjs';
  39. declare const JEST_CONFIG_EXT_ORDER: readonly string[];
  40. declare const JEST_CONFIG_EXT_TS = '.ts';
  41. declare type JSONString = string & {
  42. readonly $$type: never;
  43. };
  44. declare const NODE_MODULES: string;
  45. export declare function normalize(
  46. initialOptions: Config.InitialOptions,
  47. argv: Config.Argv,
  48. configPath?: string | null,
  49. projectIndex?: number,
  50. isProjectOptions?: boolean,
  51. ): Promise<{
  52. hasDeprecationWarnings: boolean;
  53. options: AllOptions;
  54. }>;
  55. declare const PACKAGE_JSON = 'package.json';
  56. declare type ReadConfig = {
  57. configPath: string | null | undefined;
  58. globalConfig: Config.GlobalConfig;
  59. hasDeprecationWarnings: boolean;
  60. projectConfig: Config.ProjectConfig;
  61. };
  62. export declare function readConfig(
  63. argv: Config.Argv,
  64. packageRootOrConfig: string | Config.InitialOptions,
  65. skipArgvConfigOption?: boolean,
  66. parentConfigDirname?: string | null,
  67. projectIndex?: number,
  68. skipMultipleConfigError?: boolean,
  69. ): Promise<ReadConfig>;
  70. export declare function readConfigs(
  71. argv: Config.Argv,
  72. projectPaths: Array<string>,
  73. ): Promise<{
  74. globalConfig: Config.GlobalConfig;
  75. configs: Array<Config.ProjectConfig>;
  76. hasDeprecationWarnings: boolean;
  77. }>;
  78. /**
  79. * Reads the jest config, without validating them or filling it out with defaults.
  80. * @param config The path to the file or serialized config.
  81. * @param param1 Additional options
  82. * @returns The raw initial config (not validated)
  83. */
  84. export declare function readInitialOptions(
  85. config?: string,
  86. {
  87. packageRootOrConfig,
  88. parentConfigDirname,
  89. readFromCwd,
  90. skipMultipleConfigError,
  91. }?: ReadJestConfigOptions,
  92. ): Promise<{
  93. config: Config.InitialOptions;
  94. configPath: string | null;
  95. }>;
  96. export declare interface ReadJestConfigOptions {
  97. /**
  98. * The package root or deserialized config (default is cwd)
  99. */
  100. packageRootOrConfig?: string | Config.InitialOptions;
  101. /**
  102. * When the `packageRootOrConfig` contains config, this parameter should
  103. * contain the dirname of the parent config
  104. */
  105. parentConfigDirname?: null | string;
  106. /**
  107. * Indicates whether or not to read the specified config file from disk.
  108. * When true, jest will read try to read config from the current working directory.
  109. * (default is false)
  110. */
  111. readFromCwd?: boolean;
  112. /**
  113. * Indicates whether or not to ignore the error of jest finding multiple config files.
  114. * (default is false)
  115. */
  116. skipMultipleConfigError?: boolean;
  117. }
  118. export declare const replaceRootDirInPath: (
  119. rootDir: string,
  120. filePath: string,
  121. ) => string;
  122. export {};