UNPKG

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