@pkg-nec/jest-config 30.4.2

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.
package/build/index.js ADDED
@@ -0,0 +1,2903 @@
1
+ /*!
2
+ * /**
3
+ * * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ * *
5
+ * * This source code is licensed under the MIT license found in the
6
+ * * LICENSE file in the root directory of this source tree.
7
+ * * /
8
+ */
9
+ /******/ (() => { // webpackBootstrap
10
+ /******/ "use strict";
11
+ /******/ var __webpack_modules__ = ({
12
+
13
+ /***/ "./src/Defaults.ts"
14
+ (__unused_webpack_module, exports, __webpack_require__) {
15
+
16
+
17
+
18
+ Object.defineProperty(exports, "__esModule", ({
19
+ value: true
20
+ }));
21
+ exports["default"] = void 0;
22
+ function _nodePath() {
23
+ const data = require("node:path");
24
+ _nodePath = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
29
+ function _ciInfo() {
30
+ const data = require("ci-info");
31
+ _ciInfo = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
36
+ function _jestRegexUtil() {
37
+ const data = require("@pkg-nec/jest-regex-util");
38
+ _jestRegexUtil = function () {
39
+ return data;
40
+ };
41
+ return data;
42
+ }
43
+ var _constants = __webpack_require__("./src/constants.ts");
44
+ var _getCacheDirectory = _interopRequireDefault(__webpack_require__("./src/getCacheDirectory.ts"));
45
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
46
+ /**
47
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
48
+ *
49
+ * This source code is licensed under the MIT license found in the
50
+ * LICENSE file in the root directory of this source tree.
51
+ */
52
+
53
+ const NODE_MODULES_REGEXP = (0, _jestRegexUtil().replacePathSepForRegex)(_constants.NODE_MODULES);
54
+ const defaultOptions = {
55
+ automock: false,
56
+ bail: 0,
57
+ cache: true,
58
+ cacheDirectory: (0, _getCacheDirectory.default)(),
59
+ changedFilesWithAncestor: false,
60
+ ci: _ciInfo().isCI,
61
+ clearMocks: false,
62
+ collectCoverage: false,
63
+ coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
64
+ coverageProvider: 'babel',
65
+ coverageReporters: ['json', 'text', 'lcov', 'clover'],
66
+ detectLeaks: false,
67
+ detectOpenHandles: false,
68
+ errorOnDeprecated: false,
69
+ expand: false,
70
+ extensionsToTreatAsEsm: [],
71
+ fakeTimers: {
72
+ enableGlobally: false
73
+ },
74
+ forceCoverageMatch: [],
75
+ globals: {},
76
+ haste: {
77
+ computeSha1: false,
78
+ enableSymlinks: false,
79
+ forceNodeFilesystemAPI: true,
80
+ throwOnModuleCollision: false
81
+ },
82
+ injectGlobals: true,
83
+ listTests: false,
84
+ maxConcurrency: 5,
85
+ maxWorkers: '50%',
86
+ moduleDirectories: ['node_modules'],
87
+ moduleFileExtensions: ['js', 'mjs', 'cjs', 'jsx', 'ts', 'mts', 'cts', 'tsx', 'json', 'node'],
88
+ moduleNameMapper: {},
89
+ modulePathIgnorePatterns: [],
90
+ noStackTrace: false,
91
+ notify: false,
92
+ notifyMode: 'failure-change',
93
+ openHandlesTimeout: 1000,
94
+ passWithNoTests: false,
95
+ prettierPath: 'prettier',
96
+ resetMocks: false,
97
+ resetModules: false,
98
+ restoreMocks: false,
99
+ roots: ['<rootDir>'],
100
+ runTestsByPath: false,
101
+ runner: '@pkg-nec/jest-runner',
102
+ setupFiles: [],
103
+ setupFilesAfterEnv: [],
104
+ skipFilter: false,
105
+ slowTestThreshold: 5,
106
+ snapshotFormat: {
107
+ escapeString: false,
108
+ printBasicPrototype: false
109
+ },
110
+ snapshotSerializers: [],
111
+ testEnvironment: '@pkg-nec/jest-environment-node',
112
+ testEnvironmentOptions: {},
113
+ testFailureExitCode: 1,
114
+ testLocationInResults: false,
115
+ testMatch: ['**/__tests__/**/*.?([mc])[jt]s?(x)', '**/?(*.)+(spec|test).?([mc])[jt]s?(x)'],
116
+ testPathIgnorePatterns: [NODE_MODULES_REGEXP],
117
+ testRegex: [],
118
+ testRunner: '@pkg-nec/jest-circus/runner',
119
+ testSequencer: '@pkg-nec/jest-test-sequencer',
120
+ transformIgnorePatterns: [NODE_MODULES_REGEXP, `\\.pnp\\.[^\\${_nodePath().sep}]+$`],
121
+ useStderr: false,
122
+ waitForUnhandledRejections: false,
123
+ watch: false,
124
+ watchPathIgnorePatterns: [],
125
+ watchman: true,
126
+ workerGracefulExitTimeout: 500,
127
+ workerThreads: false
128
+ };
129
+ var _default = exports["default"] = defaultOptions;
130
+
131
+ /***/ },
132
+
133
+ /***/ "./src/Deprecated.ts"
134
+ (__unused_webpack_module, exports) {
135
+
136
+
137
+
138
+ Object.defineProperty(exports, "__esModule", ({
139
+ value: true
140
+ }));
141
+ exports["default"] = void 0;
142
+ function _chalk() {
143
+ const data = _interopRequireDefault(require("chalk"));
144
+ _chalk = function () {
145
+ return data;
146
+ };
147
+ return data;
148
+ }
149
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
150
+ /**
151
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
152
+ *
153
+ * This source code is licensed under the MIT license found in the
154
+ * LICENSE file in the root directory of this source tree.
155
+ */
156
+
157
+ function formatDeprecation(message) {
158
+ const lines = [message.replaceAll(/\*(.+?)\*/g, (_, s) => _chalk().default.bold(`"${s}"`)), '', 'Please update your configuration.'];
159
+ return lines.map(s => ` ${s}`).join('\n');
160
+ }
161
+ const deprecatedOptions = {
162
+ browser: () => ` Option ${_chalk().default.bold('"browser"')} has been deprecated. Please install "browser-resolve" and use the "resolver" option in Jest configuration as shown in the documentation: https://jestjs.io/docs/configuration#resolver-string`,
163
+ collectCoverageOnlyFrom: _options => ` Option ${_chalk().default.bold('"collectCoverageOnlyFrom"')} was replaced by ${_chalk().default.bold('"collectCoverageFrom"')}.
164
+
165
+ Please update your configuration.`,
166
+ extraGlobals: _options => ` Option ${_chalk().default.bold('"extraGlobals"')} was replaced by ${_chalk().default.bold('"sandboxInjectedGlobals"')}.
167
+
168
+ Please update your configuration.`,
169
+ init: () => ` Option ${_chalk().default.bold('"init"')} has been deprecated. Please use "create-jest" package as shown in the documentation: https://jestjs.io/docs/getting-started#generate-a-basic-configuration-file`,
170
+ moduleLoader: _options => ` Option ${_chalk().default.bold('"moduleLoader"')} was replaced by ${_chalk().default.bold('"runtime"')}.
171
+
172
+ Please update your configuration.`,
173
+ preprocessorIgnorePatterns: _options => ` Option ${_chalk().default.bold('"preprocessorIgnorePatterns"')} was replaced by ${_chalk().default.bold('"transformIgnorePatterns"')}, which support multiple preprocessors.
174
+
175
+ Please update your configuration.`,
176
+ scriptPreprocessor: _options => ` Option ${_chalk().default.bold('"scriptPreprocessor"')} was replaced by ${_chalk().default.bold('"transform"')}, which support multiple preprocessors.
177
+
178
+ Please update your configuration.`,
179
+ setupTestFrameworkScriptFile: _options => ` Option ${_chalk().default.bold('"setupTestFrameworkScriptFile"')} was replaced by configuration ${_chalk().default.bold('"setupFilesAfterEnv"')}, which supports multiple paths.
180
+
181
+ Please update your configuration.`,
182
+ testPathDirs: _options => ` Option ${_chalk().default.bold('"testPathDirs"')} was replaced by ${_chalk().default.bold('"roots"')}.
183
+
184
+ Please update your configuration.
185
+ `,
186
+ testPathPattern: () => formatDeprecation('Option *testPathPattern* was replaced by *--testPathPatterns*. *--testPathPatterns* is only available as a command-line option.'),
187
+ testURL: _options => ` Option ${_chalk().default.bold('"testURL"')} was replaced by passing the URL via ${_chalk().default.bold('"testEnvironmentOptions.url"')}.
188
+
189
+ Please update your configuration.`,
190
+ timers: _options => ` Option ${_chalk().default.bold('"timers"')} was replaced by ${_chalk().default.bold('"fakeTimers"')}.
191
+
192
+ Please update your configuration.`
193
+ };
194
+ var _default = exports["default"] = deprecatedOptions;
195
+
196
+ /***/ },
197
+
198
+ /***/ "./src/Descriptions.ts"
199
+ (__unused_webpack_module, exports) {
200
+
201
+
202
+
203
+ Object.defineProperty(exports, "__esModule", ({
204
+ value: true
205
+ }));
206
+ exports["default"] = void 0;
207
+ /**
208
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
209
+ *
210
+ * This source code is licensed under the MIT license found in the
211
+ * LICENSE file in the root directory of this source tree.
212
+ */
213
+
214
+ const descriptions = {
215
+ automock: 'All imported modules in your tests should be mocked automatically',
216
+ bail: 'Stop running tests after `n` failures',
217
+ cacheDirectory: 'The directory where Jest should store its cached dependency information',
218
+ clearMocks: 'Automatically clear mock calls, instances, contexts and results before every test',
219
+ collectCoverage: 'Indicates whether the coverage information should be collected while executing the test',
220
+ collectCoverageFrom: 'An array of glob patterns indicating a set of files for which coverage information should be collected',
221
+ coverageDirectory: 'The directory where Jest should output its coverage files',
222
+ coveragePathIgnorePatterns: 'An array of regexp pattern strings used to skip coverage collection',
223
+ coverageProvider: 'Indicates which provider should be used to instrument code for coverage',
224
+ coverageReporters: 'A list of reporter names that Jest uses when writing coverage reports',
225
+ coverageThreshold: 'An object that configures minimum threshold enforcement for coverage results',
226
+ dependencyExtractor: 'A path to a custom dependency extractor',
227
+ errorOnDeprecated: 'Make calling deprecated APIs throw helpful error messages',
228
+ fakeTimers: 'The default configuration for fake timers',
229
+ forceCoverageMatch: 'Force coverage collection from ignored files using an array of glob patterns',
230
+ globalSetup: 'A path to a module which exports an async function that is triggered once before all test suites',
231
+ globalTeardown: 'A path to a module which exports an async function that is triggered once after all test suites',
232
+ globals: 'A set of global variables that need to be available in all test environments',
233
+ maxWorkers: 'The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.',
234
+ moduleDirectories: "An array of directory names to be searched recursively up from the requiring module's location",
235
+ moduleFileExtensions: 'An array of file extensions your modules use',
236
+ moduleNameMapper: 'A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module',
237
+ modulePathIgnorePatterns: "An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader",
238
+ notify: 'Activates notifications for test results',
239
+ notifyMode: 'An enum that specifies notification mode. Requires { notify: true }',
240
+ preset: "A preset that is used as a base for Jest's configuration",
241
+ projects: 'Run tests from one or more projects',
242
+ reporters: 'Use this configuration option to add custom reporters to Jest',
243
+ resetMocks: 'Automatically reset mock state before every test',
244
+ resetModules: 'Reset the module registry before running each individual test',
245
+ resolver: 'A path to a custom resolver',
246
+ restoreMocks: 'Automatically restore mock state and implementation before every test',
247
+ rootDir: 'The root directory that Jest should scan for tests and modules within',
248
+ roots: 'A list of paths to directories that Jest should use to search for files in',
249
+ runner: "Allows you to use a custom runner instead of Jest's default test runner",
250
+ setupFiles: 'The paths to modules that run some code to configure or set up the testing environment before each test',
251
+ setupFilesAfterEnv: 'A list of paths to modules that run some code to configure or set up the testing framework before each test',
252
+ slowTestThreshold: 'The number of seconds after which a test is considered as slow and reported as such in the results.',
253
+ snapshotSerializers: 'A list of paths to snapshot serializer modules Jest should use for snapshot testing',
254
+ testEnvironment: 'The test environment that will be used for testing',
255
+ testEnvironmentOptions: 'Options that will be passed to the testEnvironment',
256
+ testLocationInResults: 'Adds a location field to test results',
257
+ testMatch: 'The glob patterns Jest uses to detect test files',
258
+ testPathIgnorePatterns: 'An array of regexp pattern strings that are matched against all test paths, matched tests are skipped',
259
+ testRegex: 'The regexp pattern or array of patterns that Jest uses to detect test files',
260
+ testResultsProcessor: 'This option allows the use of a custom results processor',
261
+ testRunner: 'This option allows use of a custom test runner',
262
+ transform: 'A map from regular expressions to paths to transformers',
263
+ transformIgnorePatterns: 'An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation',
264
+ unmockedModulePathPatterns: 'An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them',
265
+ verbose: 'Indicates whether each individual test should be reported during the run',
266
+ watchPathIgnorePatterns: 'An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode',
267
+ watchman: 'Whether to use watchman for file crawling'
268
+ };
269
+ var _default = exports["default"] = descriptions;
270
+
271
+ /***/ },
272
+
273
+ /***/ "./src/ReporterValidationErrors.ts"
274
+ (__unused_webpack_module, exports, __webpack_require__) {
275
+
276
+
277
+
278
+ Object.defineProperty(exports, "__esModule", ({
279
+ value: true
280
+ }));
281
+ exports.createArrayReporterError = createArrayReporterError;
282
+ exports.createReporterError = createReporterError;
283
+ exports.validateReporters = validateReporters;
284
+ function _chalk() {
285
+ const data = _interopRequireDefault(require("chalk"));
286
+ _chalk = function () {
287
+ return data;
288
+ };
289
+ return data;
290
+ }
291
+ function _jestGetType() {
292
+ const data = require("@pkg-nec/jest-get-type");
293
+ _jestGetType = function () {
294
+ return data;
295
+ };
296
+ return data;
297
+ }
298
+ function _jestValidate() {
299
+ const data = require("@pkg-nec/jest-validate");
300
+ _jestValidate = function () {
301
+ return data;
302
+ };
303
+ return data;
304
+ }
305
+ var _utils = __webpack_require__("./src/utils.ts");
306
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
307
+ /**
308
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
309
+ *
310
+ * This source code is licensed under the MIT license found in the
311
+ * LICENSE file in the root directory of this source tree.
312
+ */
313
+
314
+ const validReporterTypes = ['array', 'string'];
315
+ const ERROR = `${_utils.BULLET}Reporter Validation Error`;
316
+
317
+ /**
318
+ * Reporter Validation Error is thrown if the given arguments
319
+ * within the reporter are not valid.
320
+ *
321
+ * This is a highly specific reporter error and in the future will be
322
+ * merged with jest-validate. Till then, we can make use of it. It works
323
+ * and that's what counts most at this time.
324
+ */
325
+ function createReporterError(reporterIndex, reporterValue) {
326
+ const errorMessage = ` Reporter at index ${reporterIndex} must be of type:\n` + ` ${_chalk().default.bold.green(validReporterTypes.join(' or '))}\n` + ' but instead received:\n' + ` ${_chalk().default.bold.red((0, _jestGetType().getType)(reporterValue))}`;
327
+ return new (_jestValidate().ValidationError)(ERROR, errorMessage, _utils.DOCUMENTATION_NOTE);
328
+ }
329
+ function createArrayReporterError(arrayReporter, reporterIndex, valueIndex, value, expectedType, valueName) {
330
+ const errorMessage = ` Unexpected value for ${valueName} ` + `at index ${valueIndex} of reporter at index ${reporterIndex}\n` + ' Expected:\n' + ` ${_chalk().default.bold.red(expectedType)}\n` + ' Got:\n' + ` ${_chalk().default.bold.green((0, _jestGetType().getType)(value))}\n` + ' Reporter configuration:\n' + ` ${_chalk().default.bold.green(JSON.stringify(arrayReporter, null, 2).split('\n').join('\n '))}`;
331
+ return new (_jestValidate().ValidationError)(ERROR, errorMessage, _utils.DOCUMENTATION_NOTE);
332
+ }
333
+ function validateReporters(reporterConfig) {
334
+ return reporterConfig.every((reporter, index) => {
335
+ if (Array.isArray(reporter)) {
336
+ validateArrayReporter(reporter, index);
337
+ } else if (typeof reporter !== 'string') {
338
+ throw createReporterError(index, reporter);
339
+ }
340
+ return true;
341
+ });
342
+ }
343
+ function validateArrayReporter(arrayReporter, reporterIndex) {
344
+ const [path, options] = arrayReporter;
345
+ if (typeof path !== 'string') {
346
+ throw createArrayReporterError(arrayReporter, reporterIndex, 0, path, 'string', 'Path');
347
+ } else if (typeof options !== 'object') {
348
+ throw createArrayReporterError(arrayReporter, reporterIndex, 1, options, 'object', 'Reporter Configuration');
349
+ }
350
+ }
351
+
352
+ /***/ },
353
+
354
+ /***/ "./src/ValidConfig.ts"
355
+ (__unused_webpack_module, exports, __webpack_require__) {
356
+
357
+
358
+
359
+ Object.defineProperty(exports, "__esModule", ({
360
+ value: true
361
+ }));
362
+ exports.initialProjectOptions = exports.initialOptions = void 0;
363
+ function _jestRegexUtil() {
364
+ const data = require("@pkg-nec/jest-regex-util");
365
+ _jestRegexUtil = function () {
366
+ return data;
367
+ };
368
+ return data;
369
+ }
370
+ function _jestValidate() {
371
+ const data = require("@pkg-nec/jest-validate");
372
+ _jestValidate = function () {
373
+ return data;
374
+ };
375
+ return data;
376
+ }
377
+ function _prettyFormat() {
378
+ const data = require("@pkg-nec/pretty-format");
379
+ _prettyFormat = function () {
380
+ return data;
381
+ };
382
+ return data;
383
+ }
384
+ var _constants = __webpack_require__("./src/constants.ts");
385
+ /**
386
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
387
+ *
388
+ * This source code is licensed under the MIT license found in the
389
+ * LICENSE file in the root directory of this source tree.
390
+ */
391
+
392
+ const NODE_MODULES_REGEXP = (0, _jestRegexUtil().replacePathSepForRegex)(_constants.NODE_MODULES);
393
+ const initialOptions = exports.initialOptions = {
394
+ automock: false,
395
+ bail: (0, _jestValidate().multipleValidOptions)(false, 0),
396
+ cache: true,
397
+ cacheDirectory: '/tmp/user/jest',
398
+ changedFilesWithAncestor: false,
399
+ changedSince: 'master',
400
+ ci: false,
401
+ clearMocks: false,
402
+ collectCoverage: true,
403
+ collectCoverageFrom: ['src', '!public'],
404
+ collectTests: false,
405
+ coverageDirectory: 'coverage',
406
+ coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
407
+ coverageProvider: 'v8',
408
+ coverageReporters: ['json', 'text', 'lcov', 'clover'],
409
+ coverageThreshold: {
410
+ global: {
411
+ branches: 50,
412
+ functions: 100,
413
+ lines: 100,
414
+ statements: 100
415
+ }
416
+ },
417
+ dependencyExtractor: '<rootDir>/dependencyExtractor.js',
418
+ detectLeaks: false,
419
+ detectOpenHandles: false,
420
+ displayName: (0, _jestValidate().multipleValidOptions)('test-config', {
421
+ color: 'blue',
422
+ name: 'test-config'
423
+ }),
424
+ errorOnDeprecated: false,
425
+ expand: false,
426
+ extensionsToTreatAsEsm: [],
427
+ fakeTimers: {
428
+ advanceTimers: (0, _jestValidate().multipleValidOptions)(40, true),
429
+ doNotFake: ['Date', 'hrtime', 'nextTick', 'performance', 'queueMicrotask', 'requestAnimationFrame', 'cancelAnimationFrame', 'requestIdleCallback', 'cancelIdleCallback', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout'],
430
+ enableGlobally: true,
431
+ legacyFakeTimers: false,
432
+ now: 1_483_228_800_000,
433
+ timerLimit: 1000
434
+ },
435
+ filter: '<rootDir>/filter.js',
436
+ forceCoverageMatch: ['**/*.t.js'],
437
+ forceExit: false,
438
+ globalSetup: 'setup.js',
439
+ globalTeardown: 'teardown.js',
440
+ globals: {
441
+ __DEV__: true
442
+ },
443
+ haste: {
444
+ computeSha1: true,
445
+ defaultPlatform: 'ios',
446
+ enableSymlinks: false,
447
+ forceNodeFilesystemAPI: true,
448
+ hasteImplModulePath: '<rootDir>/haste_impl.js',
449
+ hasteMapModulePath: '',
450
+ platforms: ['ios', 'android'],
451
+ retainAllFiles: false,
452
+ throwOnModuleCollision: false
453
+ },
454
+ id: 'string',
455
+ injectGlobals: true,
456
+ json: false,
457
+ lastCommit: false,
458
+ listTests: false,
459
+ logHeapUsage: true,
460
+ maxConcurrency: 5,
461
+ maxWorkers: '50%',
462
+ moduleDirectories: ['node_modules'],
463
+ moduleFileExtensions: ['js', 'mjs', 'cjs', 'json', 'jsx', 'ts', 'mts', 'cts', 'tsx', 'node'],
464
+ moduleNameMapper: {
465
+ '^React$': '<rootDir>/node_modules/react'
466
+ },
467
+ modulePathIgnorePatterns: ['<rootDir>/build/'],
468
+ modulePaths: ['/shared/vendor/modules'],
469
+ noStackTrace: false,
470
+ notify: false,
471
+ notifyMode: 'failure-change',
472
+ onlyChanged: false,
473
+ onlyFailures: false,
474
+ openHandlesTimeout: 1000,
475
+ passWithNoTests: false,
476
+ preset: 'react-native',
477
+ prettierPath: '<rootDir>/node_modules/prettier',
478
+ projects: ['project-a', 'project-b/'],
479
+ randomize: false,
480
+ reporters: ['default', 'custom-reporter-1', ['custom-reporter-2', {
481
+ configValue: true
482
+ }]],
483
+ resetMocks: false,
484
+ resetModules: false,
485
+ resolver: '<rootDir>/resolver.js',
486
+ restoreMocks: false,
487
+ rootDir: '/',
488
+ roots: ['<rootDir>'],
489
+ runTestsByPath: false,
490
+ runner: (0, _jestValidate().multipleValidOptions)('jest-runner', ['jest-runner', ['jest-runner', {
491
+ option: true
492
+ }]]),
493
+ runtime: '<rootDir>',
494
+ sandboxInjectedGlobals: [],
495
+ setupFiles: ['<rootDir>/setup.js'],
496
+ setupFilesAfterEnv: ['<rootDir>/testSetupFile.js'],
497
+ showSeed: false,
498
+ silent: true,
499
+ skipFilter: false,
500
+ skipNodeResolution: false,
501
+ slowTestThreshold: 5,
502
+ snapshotFormat: _prettyFormat().DEFAULT_OPTIONS,
503
+ snapshotResolver: '<rootDir>/snapshotResolver.js',
504
+ snapshotSerializers: ['my-serializer-module'],
505
+ testEnvironment: '@pkg-nec/jest-environment-node',
506
+ testEnvironmentOptions: {
507
+ url: 'http://localhost',
508
+ userAgent: 'Agent/007'
509
+ },
510
+ testFailureExitCode: 1,
511
+ testLocationInResults: false,
512
+ testMatch: (0, _jestValidate().multipleValidOptions)('**/__tests__/**/?(*.)+(spec|test).?([mc])[jt]s?(x)', ['**/__tests__/**/*.?([mc])[jt]s?(x)', '**/?(*.)+(spec|test).?([mc])[jt]s?(x)']),
513
+ testNamePattern: 'test signature',
514
+ testPathIgnorePatterns: [NODE_MODULES_REGEXP],
515
+ testRegex: (0, _jestValidate().multipleValidOptions)('(/__tests__/.*|(\\.|/)(test|spec))\\.[mc]?[jt]sx?$', ['/__tests__/\\.test\\.[mc]?[jt]sx?$', '/__tests__/\\.spec\\.[mc]?[jt]sx?$']),
516
+ testResultsProcessor: 'processor-node-module',
517
+ testRunner: 'circus',
518
+ testSequencer: '@pkg-nec/jest-test-sequencer',
519
+ testTimeout: 5000,
520
+ transform: {
521
+ '\\.js$': '<rootDir>/preprocessor.js'
522
+ },
523
+ transformIgnorePatterns: [NODE_MODULES_REGEXP],
524
+ unmockedModulePathPatterns: ['mock'],
525
+ updateSnapshot: true,
526
+ useStderr: false,
527
+ verbose: false,
528
+ waitForUnhandledRejections: false,
529
+ watch: false,
530
+ watchAll: false,
531
+ watchPathIgnorePatterns: ['<rootDir>/e2e/'],
532
+ watchPlugins: ['path/to/yourWatchPlugin', ['jest-watch-typeahead/filename', {
533
+ key: 'k',
534
+ prompt: 'do something with my custom prompt'
535
+ }]],
536
+ watchman: true,
537
+ workerGracefulExitTimeout: 500,
538
+ workerIdleMemoryLimit: (0, _jestValidate().multipleValidOptions)(0.2, '50%'),
539
+ workerThreads: true
540
+ };
541
+ const initialProjectOptions = exports.initialProjectOptions = {
542
+ automock: false,
543
+ cache: true,
544
+ cacheDirectory: '/tmp/user/jest',
545
+ clearMocks: false,
546
+ collectCoverage: false,
547
+ collectCoverageFrom: ['src', '!public'],
548
+ coverageDirectory: 'coverage',
549
+ coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
550
+ coverageProvider: 'v8',
551
+ coverageReporters: ['json', 'text', 'lcov', 'clover'],
552
+ dependencyExtractor: '<rootDir>/dependencyExtractor.js',
553
+ detectLeaks: false,
554
+ detectOpenHandles: false,
555
+ displayName: (0, _jestValidate().multipleValidOptions)('test-config', {
556
+ color: 'blue',
557
+ name: 'test-config'
558
+ }),
559
+ errorOnDeprecated: false,
560
+ extensionsToTreatAsEsm: [],
561
+ fakeTimers: {
562
+ advanceTimers: (0, _jestValidate().multipleValidOptions)(40, true),
563
+ doNotFake: ['Date', 'hrtime', 'nextTick', 'performance', 'queueMicrotask', 'requestAnimationFrame', 'cancelAnimationFrame', 'requestIdleCallback', 'cancelIdleCallback', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout'],
564
+ enableGlobally: true,
565
+ legacyFakeTimers: false,
566
+ now: 1_483_228_800_000,
567
+ timerLimit: 1000
568
+ },
569
+ filter: '<rootDir>/filter.js',
570
+ forceCoverageMatch: ['**/*.t.js'],
571
+ globalSetup: 'setup.js',
572
+ globalTeardown: 'teardown.js',
573
+ globals: {
574
+ __DEV__: true
575
+ },
576
+ haste: {
577
+ computeSha1: true,
578
+ defaultPlatform: 'ios',
579
+ enableSymlinks: false,
580
+ forceNodeFilesystemAPI: true,
581
+ hasteImplModulePath: '<rootDir>/haste_impl.js',
582
+ hasteMapModulePath: '',
583
+ platforms: ['ios', 'android'],
584
+ retainAllFiles: false,
585
+ throwOnModuleCollision: false
586
+ },
587
+ id: 'string',
588
+ injectGlobals: true,
589
+ moduleDirectories: ['node_modules'],
590
+ moduleFileExtensions: ['js', 'mjs', 'cjs', 'json', 'jsx', 'ts', 'mts', 'cts', 'tsx', 'node'],
591
+ moduleNameMapper: {
592
+ '^React$': '<rootDir>/node_modules/react'
593
+ },
594
+ modulePathIgnorePatterns: ['<rootDir>/build/'],
595
+ modulePaths: ['/shared/vendor/modules'],
596
+ openHandlesTimeout: 1000,
597
+ preset: 'react-native',
598
+ prettierPath: '<rootDir>/node_modules/prettier',
599
+ reporters: ['default', 'custom-reporter-1', ['custom-reporter-2', {
600
+ configValue: true
601
+ }]],
602
+ resetMocks: false,
603
+ resetModules: false,
604
+ resolver: '<rootDir>/resolver.js',
605
+ restoreMocks: false,
606
+ rootDir: '/',
607
+ roots: ['<rootDir>'],
608
+ runner: (0, _jestValidate().multipleValidOptions)('jest-runner', ['jest-runner', ['jest-runner', {
609
+ option: true
610
+ }]]),
611
+ runtime: '<rootDir>',
612
+ sandboxInjectedGlobals: [],
613
+ setupFiles: ['<rootDir>/setup.js'],
614
+ setupFilesAfterEnv: ['<rootDir>/testSetupFile.js'],
615
+ silent: false,
616
+ skipFilter: false,
617
+ skipNodeResolution: false,
618
+ slowTestThreshold: 5,
619
+ snapshotFormat: _prettyFormat().DEFAULT_OPTIONS,
620
+ snapshotResolver: '<rootDir>/snapshotResolver.js',
621
+ snapshotSerializers: ['my-serializer-module'],
622
+ testEnvironment: '@pkg-nec/jest-environment-node',
623
+ testEnvironmentOptions: {
624
+ url: 'http://localhost',
625
+ userAgent: 'Agent/007'
626
+ },
627
+ testLocationInResults: false,
628
+ testMatch: ['**/__tests__/**/*.?([mc])[jt]s?(x)', '**/?(*.)+(spec|test).?([mc])[jt]s?(x)'],
629
+ testPathIgnorePatterns: [NODE_MODULES_REGEXP],
630
+ testRegex: (0, _jestValidate().multipleValidOptions)('(/__tests__/.*|(\\.|/)(test|spec))\\.[mc]?[jt]sx?$', ['/__tests__/\\.test\\.[mc]?[jt]sx?$', '/__tests__/\\.spec\\.[mc]?[jt]sx?$']),
631
+ testRunner: 'circus',
632
+ testTimeout: 5000,
633
+ transform: {
634
+ '\\.js$': '<rootDir>/preprocessor.js'
635
+ },
636
+ transformIgnorePatterns: [NODE_MODULES_REGEXP],
637
+ unmockedModulePathPatterns: ['mock'],
638
+ verbose: false,
639
+ waitForUnhandledRejections: false,
640
+ watchPathIgnorePatterns: ['<rootDir>/e2e/'],
641
+ workerIdleMemoryLimit: (0, _jestValidate().multipleValidOptions)(0.2, '50%')
642
+ };
643
+
644
+ /***/ },
645
+
646
+ /***/ "./src/color.ts"
647
+ (__unused_webpack_module, exports) {
648
+
649
+
650
+
651
+ Object.defineProperty(exports, "__esModule", ({
652
+ value: true
653
+ }));
654
+ exports.getDisplayNameColor = void 0;
655
+ function _nodeCrypto() {
656
+ const data = require("node:crypto");
657
+ _nodeCrypto = function () {
658
+ return data;
659
+ };
660
+ return data;
661
+ }
662
+ /**
663
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
664
+ *
665
+ * This source code is licensed under the MIT license found in the
666
+ * LICENSE file in the root directory of this source tree.
667
+ */
668
+
669
+ const colors = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
670
+ const getDisplayNameColor = seed => {
671
+ if (seed === undefined) {
672
+ return 'white';
673
+ }
674
+ const hash = (0, _nodeCrypto().createHash)('sha256');
675
+ hash.update(seed);
676
+ const num = hash.digest().readUInt32LE(0);
677
+ return colors[num % colors.length];
678
+ };
679
+ exports.getDisplayNameColor = getDisplayNameColor;
680
+
681
+ /***/ },
682
+
683
+ /***/ "./src/constants.ts"
684
+ (__unused_webpack_module, exports) {
685
+
686
+
687
+
688
+ Object.defineProperty(exports, "__esModule", ({
689
+ value: true
690
+ }));
691
+ exports.PACKAGE_JSON = exports.NODE_MODULES = exports.JEST_CONFIG_EXT_TS = exports.JEST_CONFIG_EXT_ORDER = exports.JEST_CONFIG_EXT_MTS = exports.JEST_CONFIG_EXT_MJS = exports.JEST_CONFIG_EXT_JSON = exports.JEST_CONFIG_EXT_JS = exports.JEST_CONFIG_EXT_CTS = exports.JEST_CONFIG_EXT_CJS = exports.JEST_CONFIG_BASE_NAME = exports.DEFAULT_JS_PATTERN = void 0;
692
+ function path() {
693
+ const data = _interopRequireWildcard(require("node:path"));
694
+ path = function () {
695
+ return data;
696
+ };
697
+ return data;
698
+ }
699
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
700
+ /**
701
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
702
+ *
703
+ * This source code is licensed under the MIT license found in the
704
+ * LICENSE file in the root directory of this source tree.
705
+ */
706
+
707
+ const NODE_MODULES = exports.NODE_MODULES = `${path().sep}node_modules${path().sep}`;
708
+ const DEFAULT_JS_PATTERN = exports.DEFAULT_JS_PATTERN = '\\.[jt]sx?$';
709
+ const PACKAGE_JSON = exports.PACKAGE_JSON = 'package.json';
710
+ const JEST_CONFIG_BASE_NAME = exports.JEST_CONFIG_BASE_NAME = 'jest.config';
711
+ const JEST_CONFIG_EXT_CJS = exports.JEST_CONFIG_EXT_CJS = '.cjs';
712
+ const JEST_CONFIG_EXT_MJS = exports.JEST_CONFIG_EXT_MJS = '.mjs';
713
+ const JEST_CONFIG_EXT_MTS = exports.JEST_CONFIG_EXT_MTS = '.mts';
714
+ const JEST_CONFIG_EXT_JS = exports.JEST_CONFIG_EXT_JS = '.js';
715
+ const JEST_CONFIG_EXT_TS = exports.JEST_CONFIG_EXT_TS = '.ts';
716
+ const JEST_CONFIG_EXT_CTS = exports.JEST_CONFIG_EXT_CTS = '.cts';
717
+ const JEST_CONFIG_EXT_JSON = exports.JEST_CONFIG_EXT_JSON = '.json';
718
+ const JEST_CONFIG_EXT_ORDER = exports.JEST_CONFIG_EXT_ORDER = Object.freeze([JEST_CONFIG_EXT_JS, JEST_CONFIG_EXT_TS, JEST_CONFIG_EXT_MJS, JEST_CONFIG_EXT_MTS, JEST_CONFIG_EXT_CJS, JEST_CONFIG_EXT_CTS, JEST_CONFIG_EXT_JSON]);
719
+
720
+ /***/ },
721
+
722
+ /***/ "./src/getCacheDirectory.ts"
723
+ (__unused_webpack_module, exports) {
724
+
725
+
726
+
727
+ Object.defineProperty(exports, "__esModule", ({
728
+ value: true
729
+ }));
730
+ exports["default"] = void 0;
731
+ function _nodeOs() {
732
+ const data = require("node:os");
733
+ _nodeOs = function () {
734
+ return data;
735
+ };
736
+ return data;
737
+ }
738
+ function path() {
739
+ const data = _interopRequireWildcard(require("node:path"));
740
+ path = function () {
741
+ return data;
742
+ };
743
+ return data;
744
+ }
745
+ function _jestUtil() {
746
+ const data = require("@pkg-nec/jest-util");
747
+ _jestUtil = function () {
748
+ return data;
749
+ };
750
+ return data;
751
+ }
752
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
753
+ /**
754
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
755
+ *
756
+ * This source code is licensed under the MIT license found in the
757
+ * LICENSE file in the root directory of this source tree.
758
+ */
759
+
760
+ const getCacheDirectory = () => {
761
+ const {
762
+ getuid
763
+ } = process;
764
+ const tmpdirPath = path().join((0, _jestUtil().tryRealpath)((0, _nodeOs().tmpdir)()), 'jest');
765
+ if (getuid == null) {
766
+ return tmpdirPath;
767
+ } else {
768
+ // On some platforms tmpdir() is `/tmp`, causing conflicts between different
769
+ // users and permission issues. Adding an additional subdivision by UID can
770
+ // help.
771
+ return `${tmpdirPath}_${getuid.call(process).toString(36)}`;
772
+ }
773
+ };
774
+ var _default = exports["default"] = getCacheDirectory;
775
+
776
+ /***/ },
777
+
778
+ /***/ "./src/getMaxWorkers.ts"
779
+ (__unused_webpack_module, exports) {
780
+
781
+
782
+
783
+ Object.defineProperty(exports, "__esModule", ({
784
+ value: true
785
+ }));
786
+ exports["default"] = getMaxWorkers;
787
+ function _nodeOs() {
788
+ const data = require("node:os");
789
+ _nodeOs = function () {
790
+ return data;
791
+ };
792
+ return data;
793
+ }
794
+ /**
795
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
796
+ *
797
+ * This source code is licensed under the MIT license found in the
798
+ * LICENSE file in the root directory of this source tree.
799
+ */
800
+
801
+ function getMaxWorkers(argv, defaultOptions) {
802
+ if (argv.runInBand) {
803
+ return 1;
804
+ } else if (argv.maxWorkers) {
805
+ return parseWorkers(argv.maxWorkers);
806
+ } else if (defaultOptions && defaultOptions.maxWorkers) {
807
+ return parseWorkers(defaultOptions.maxWorkers);
808
+ } else {
809
+ // In watch mode, Jest should be unobtrusive and not use all available CPUs.
810
+ const numCpus = (0, _nodeOs().availableParallelism)();
811
+ const isWatchModeEnabled = argv.watch || argv.watchAll;
812
+ return Math.max(isWatchModeEnabled ? Math.floor(numCpus / 2) : numCpus - 1, 1);
813
+ }
814
+ }
815
+ const parseWorkers = maxWorkers => {
816
+ const parsed = Number.parseInt(maxWorkers.toString(), 10);
817
+ if (typeof maxWorkers === 'string' && maxWorkers.trim().endsWith('%') && parsed > 0 && parsed <= 100) {
818
+ const numCpus = (0, _nodeOs().availableParallelism)();
819
+ const workers = Math.floor(parsed / 100 * numCpus);
820
+ return Math.max(workers, 1);
821
+ }
822
+ return parsed > 0 ? parsed : 1;
823
+ };
824
+
825
+ /***/ },
826
+
827
+ /***/ "./src/index.ts"
828
+ (__unused_webpack_module, exports, __webpack_require__) {
829
+
830
+
831
+
832
+ Object.defineProperty(exports, "__esModule", ({
833
+ value: true
834
+ }));
835
+ exports.constants = void 0;
836
+ Object.defineProperty(exports, "defaults", ({
837
+ enumerable: true,
838
+ get: function () {
839
+ return _Defaults.default;
840
+ }
841
+ }));
842
+ exports.defineConfig = defineConfig;
843
+ Object.defineProperty(exports, "deprecationEntries", ({
844
+ enumerable: true,
845
+ get: function () {
846
+ return _Deprecated.default;
847
+ }
848
+ }));
849
+ Object.defineProperty(exports, "descriptions", ({
850
+ enumerable: true,
851
+ get: function () {
852
+ return _Descriptions.default;
853
+ }
854
+ }));
855
+ Object.defineProperty(exports, "isJSONString", ({
856
+ enumerable: true,
857
+ get: function () {
858
+ return _utils.isJSONString;
859
+ }
860
+ }));
861
+ exports.mergeConfig = mergeConfig;
862
+ Object.defineProperty(exports, "normalize", ({
863
+ enumerable: true,
864
+ get: function () {
865
+ return _normalize.default;
866
+ }
867
+ }));
868
+ exports.readConfig = readConfig;
869
+ exports.readConfigs = readConfigs;
870
+ exports.readInitialOptions = readInitialOptions;
871
+ Object.defineProperty(exports, "replaceRootDirInPath", ({
872
+ enumerable: true,
873
+ get: function () {
874
+ return _utils.replaceRootDirInPath;
875
+ }
876
+ }));
877
+ function path() {
878
+ const data = _interopRequireWildcard(require("node:path"));
879
+ path = function () {
880
+ return data;
881
+ };
882
+ return data;
883
+ }
884
+ function _chalk() {
885
+ const data = _interopRequireDefault(require("chalk"));
886
+ _chalk = function () {
887
+ return data;
888
+ };
889
+ return data;
890
+ }
891
+ function _deepmerge() {
892
+ const data = _interopRequireDefault(require("deepmerge"));
893
+ _deepmerge = function () {
894
+ return data;
895
+ };
896
+ return data;
897
+ }
898
+ function fs() {
899
+ const data = _interopRequireWildcard(require("graceful-fs"));
900
+ fs = function () {
901
+ return data;
902
+ };
903
+ return data;
904
+ }
905
+ function _jestUtil() {
906
+ const data = require("@pkg-nec/jest-util");
907
+ _jestUtil = function () {
908
+ return data;
909
+ };
910
+ return data;
911
+ }
912
+ var constants = _interopRequireWildcard(__webpack_require__("./src/constants.ts"));
913
+ exports.constants = constants;
914
+ var _normalize = _interopRequireDefault(__webpack_require__("./src/normalize.ts"));
915
+ var _readConfigFileAndSetRootDir = _interopRequireDefault(__webpack_require__("./src/readConfigFileAndSetRootDir.ts"));
916
+ var _resolveConfigPath = _interopRequireDefault(__webpack_require__("./src/resolveConfigPath.ts"));
917
+ var _utils = __webpack_require__("./src/utils.ts");
918
+ var _Deprecated = _interopRequireDefault(__webpack_require__("./src/Deprecated.ts"));
919
+ var _Defaults = _interopRequireDefault(__webpack_require__("./src/Defaults.ts"));
920
+ var _Descriptions = _interopRequireDefault(__webpack_require__("./src/Descriptions.ts"));
921
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
922
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
923
+ /**
924
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
925
+ *
926
+ * This source code is licensed under the MIT license found in the
927
+ * LICENSE file in the root directory of this source tree.
928
+ */
929
+
930
+ /**
931
+ * Type helper to make it easier to use Jest config accepts a direct JestTestConfigObject object, or a function that returns it. The function receives a JestTestConfigObject object.
932
+ */
933
+
934
+ function defineConfig(config) {
935
+ return config;
936
+ }
937
+
938
+ /**
939
+ * Merges two configuration objects, where the second object takes precedence over the first one.
940
+ */
941
+ function mergeConfig(defaults, overrides) {
942
+ if (typeof defaults === 'function' || typeof overrides === 'function') {
943
+ throw new TypeError('Cannot merge config in form of callback');
944
+ }
945
+ return _deepmerge().default.all([defaults, overrides]);
946
+ }
947
+ async function readConfig(argv, packageRootOrConfig,
948
+ // Whether it needs to look into `--config` arg passed to CLI.
949
+ // It only used to read initial config. If the initial config contains
950
+ // `project` property, we don't want to read `--config` value and rather
951
+ // read individual configs for every project.
952
+ skipArgvConfigOption, parentConfigDirname, projectIndex = Number.POSITIVE_INFINITY, skipMultipleConfigError = false) {
953
+ const {
954
+ config: initialOptions,
955
+ configPath
956
+ } = await readInitialOptions(argv.config, {
957
+ packageRootOrConfig,
958
+ parentConfigDirname,
959
+ readFromCwd: skipArgvConfigOption,
960
+ skipMultipleConfigError
961
+ });
962
+ const packageRoot = typeof packageRootOrConfig === 'string' ? path().resolve(packageRootOrConfig) : undefined;
963
+ const {
964
+ options,
965
+ hasDeprecationWarnings
966
+ } = await (0, _normalize.default)(initialOptions, argv, configPath, projectIndex, skipArgvConfigOption && !(packageRoot === parentConfigDirname));
967
+ const {
968
+ globalConfig,
969
+ projectConfig
970
+ } = groupOptions(options);
971
+ return {
972
+ configPath,
973
+ globalConfig,
974
+ hasDeprecationWarnings,
975
+ projectConfig
976
+ };
977
+ }
978
+ const groupOptions = options => ({
979
+ globalConfig: Object.freeze({
980
+ bail: options.bail,
981
+ changedFilesWithAncestor: options.changedFilesWithAncestor,
982
+ changedSince: options.changedSince,
983
+ ci: options.ci,
984
+ collectCoverage: options.collectCoverage,
985
+ collectCoverageFrom: options.collectCoverageFrom,
986
+ collectTests: options.collectTests,
987
+ coverageDirectory: options.coverageDirectory,
988
+ coverageProvider: options.coverageProvider,
989
+ coverageReporters: options.coverageReporters,
990
+ coverageThreshold: options.coverageThreshold,
991
+ detectLeaks: options.detectLeaks,
992
+ detectOpenHandles: options.detectOpenHandles,
993
+ errorOnDeprecated: options.errorOnDeprecated,
994
+ expand: options.expand,
995
+ filter: options.filter,
996
+ findRelatedTests: options.findRelatedTests,
997
+ forceExit: options.forceExit,
998
+ globalSetup: options.globalSetup,
999
+ globalTeardown: options.globalTeardown,
1000
+ json: options.json,
1001
+ lastCommit: options.lastCommit,
1002
+ listTests: options.listTests,
1003
+ logHeapUsage: options.logHeapUsage,
1004
+ maxConcurrency: options.maxConcurrency,
1005
+ maxWorkers: options.maxWorkers,
1006
+ noSCM: undefined,
1007
+ noStackTrace: options.noStackTrace,
1008
+ nonFlagArgs: options.nonFlagArgs,
1009
+ notify: options.notify,
1010
+ notifyMode: options.notifyMode,
1011
+ onlyChanged: options.onlyChanged,
1012
+ onlyFailures: options.onlyFailures,
1013
+ openHandlesTimeout: options.openHandlesTimeout,
1014
+ outputFile: options.outputFile,
1015
+ passWithNoTests: options.passWithNoTests,
1016
+ projects: options.projects,
1017
+ randomize: options.randomize,
1018
+ replname: options.replname,
1019
+ reporters: options.reporters,
1020
+ rootDir: options.rootDir,
1021
+ runInBand: options.runInBand,
1022
+ runTestsByPath: options.runTestsByPath,
1023
+ seed: options.seed,
1024
+ shard: options.shard,
1025
+ showSeed: options.showSeed,
1026
+ silent: options.silent,
1027
+ skipFilter: options.skipFilter,
1028
+ snapshotFormat: options.snapshotFormat,
1029
+ testFailureExitCode: options.testFailureExitCode,
1030
+ testNamePattern: options.testNamePattern,
1031
+ testPathPatterns: options.testPathPatterns,
1032
+ testResultsProcessor: options.testResultsProcessor,
1033
+ testSequencer: options.testSequencer,
1034
+ testTimeout: options.testTimeout,
1035
+ updateSnapshot: options.updateSnapshot,
1036
+ useStderr: options.useStderr,
1037
+ verbose: options.verbose,
1038
+ waitForUnhandledRejections: options.waitForUnhandledRejections,
1039
+ watch: options.watch,
1040
+ watchAll: options.watchAll,
1041
+ watchPlugins: options.watchPlugins,
1042
+ watchman: options.watchman,
1043
+ workerGracefulExitTimeout: options.workerGracefulExitTimeout,
1044
+ workerIdleMemoryLimit: options.workerIdleMemoryLimit,
1045
+ workerThreads: options.workerThreads
1046
+ }),
1047
+ projectConfig: Object.freeze({
1048
+ automock: options.automock,
1049
+ cache: options.cache,
1050
+ cacheDirectory: options.cacheDirectory,
1051
+ clearMocks: options.clearMocks,
1052
+ collectCoverage: options.collectCoverage,
1053
+ collectCoverageFrom: options.collectCoverageFrom,
1054
+ coverageDirectory: options.coverageDirectory,
1055
+ coveragePathIgnorePatterns: options.coveragePathIgnorePatterns,
1056
+ coverageProvider: options.coverageProvider,
1057
+ coverageReporters: options.coverageReporters,
1058
+ cwd: options.cwd,
1059
+ dependencyExtractor: options.dependencyExtractor,
1060
+ detectLeaks: options.detectLeaks,
1061
+ detectOpenHandles: options.detectOpenHandles,
1062
+ displayName: options.displayName,
1063
+ errorOnDeprecated: options.errorOnDeprecated,
1064
+ extensionsToTreatAsEsm: options.extensionsToTreatAsEsm,
1065
+ fakeTimers: options.fakeTimers,
1066
+ filter: options.filter,
1067
+ forceCoverageMatch: options.forceCoverageMatch,
1068
+ globalSetup: options.globalSetup,
1069
+ globalTeardown: options.globalTeardown,
1070
+ globals: options.globals,
1071
+ haste: options.haste,
1072
+ id: options.id,
1073
+ injectGlobals: options.injectGlobals,
1074
+ moduleDirectories: options.moduleDirectories,
1075
+ moduleFileExtensions: options.moduleFileExtensions,
1076
+ moduleNameMapper: options.moduleNameMapper,
1077
+ modulePathIgnorePatterns: options.modulePathIgnorePatterns,
1078
+ modulePaths: options.modulePaths,
1079
+ openHandlesTimeout: options.openHandlesTimeout,
1080
+ prettierPath: options.prettierPath,
1081
+ reporters: options.reporters,
1082
+ resetMocks: options.resetMocks,
1083
+ resetModules: options.resetModules,
1084
+ resolver: options.resolver,
1085
+ restoreMocks: options.restoreMocks,
1086
+ rootDir: options.rootDir,
1087
+ roots: options.roots,
1088
+ runner: options.runner,
1089
+ runnerOptions: options.runnerOptions,
1090
+ runtime: options.runtime,
1091
+ sandboxInjectedGlobals: options.sandboxInjectedGlobals,
1092
+ setupFiles: options.setupFiles,
1093
+ setupFilesAfterEnv: options.setupFilesAfterEnv,
1094
+ silent: options.silent,
1095
+ skipFilter: options.skipFilter,
1096
+ skipNodeResolution: options.skipNodeResolution,
1097
+ slowTestThreshold: options.slowTestThreshold,
1098
+ snapshotFormat: options.snapshotFormat,
1099
+ snapshotResolver: options.snapshotResolver,
1100
+ snapshotSerializers: options.snapshotSerializers,
1101
+ testEnvironment: options.testEnvironment,
1102
+ testEnvironmentOptions: options.testEnvironmentOptions,
1103
+ testLocationInResults: options.testLocationInResults,
1104
+ testMatch: options.testMatch,
1105
+ testPathIgnorePatterns: options.testPathIgnorePatterns,
1106
+ testRegex: options.testRegex,
1107
+ testRunner: options.testRunner,
1108
+ testTimeout: options.testTimeout,
1109
+ transform: options.transform,
1110
+ transformIgnorePatterns: options.transformIgnorePatterns,
1111
+ unmockedModulePathPatterns: options.unmockedModulePathPatterns,
1112
+ verbose: options.verbose,
1113
+ waitForUnhandledRejections: options.waitForUnhandledRejections,
1114
+ watchPathIgnorePatterns: options.watchPathIgnorePatterns
1115
+ })
1116
+ });
1117
+ const ensureNoDuplicateConfigs = (parsedConfigs, projects) => {
1118
+ if (projects.length <= 1) {
1119
+ return;
1120
+ }
1121
+ const configPathMap = new Map();
1122
+ for (const config of parsedConfigs) {
1123
+ const {
1124
+ configPath
1125
+ } = config;
1126
+ if (configPathMap.has(configPath)) {
1127
+ const message = `Whoops! Two projects resolved to the same config path: ${_chalk().default.bold(String(configPath))}:
1128
+
1129
+ Project 1: ${_chalk().default.bold(projects[parsedConfigs.indexOf(config)])}
1130
+ Project 2: ${_chalk().default.bold(projects[parsedConfigs.indexOf(configPathMap.get(configPath))])}
1131
+
1132
+ This usually means that your ${_chalk().default.bold('"projects"')} config includes a directory that doesn't have any configuration recognizable by Jest. Please fix it.
1133
+ `;
1134
+ throw new Error(message);
1135
+ }
1136
+ if (configPath !== null) {
1137
+ configPathMap.set(configPath, config);
1138
+ }
1139
+ }
1140
+ };
1141
+ /**
1142
+ * Reads the jest config, without validating them or filling it out with defaults.
1143
+ * @param config The path to the file or serialized config.
1144
+ * @param param1 Additional options
1145
+ * @returns The raw initial config (not validated)
1146
+ */
1147
+ async function readInitialOptions(config, {
1148
+ packageRootOrConfig = process.cwd(),
1149
+ parentConfigDirname = null,
1150
+ readFromCwd = false,
1151
+ skipMultipleConfigError = false
1152
+ } = {}) {
1153
+ if (typeof packageRootOrConfig !== 'string') {
1154
+ if (parentConfigDirname) {
1155
+ const rawOptions = packageRootOrConfig;
1156
+ rawOptions.rootDir = rawOptions.rootDir ? (0, _utils.replaceRootDirInPath)(parentConfigDirname, rawOptions.rootDir) : parentConfigDirname;
1157
+ return {
1158
+ config: rawOptions,
1159
+ configPath: null
1160
+ };
1161
+ } else {
1162
+ throw new Error('Jest: Cannot use configuration as an object without a file path.');
1163
+ }
1164
+ }
1165
+ if ((0, _utils.isJSONString)(config)) {
1166
+ try {
1167
+ // A JSON string was passed to `--config` argument and we can parse it
1168
+ // and use as is.
1169
+ const initialOptions = JSON.parse(config);
1170
+ // NOTE: we might need to resolve this dir to an absolute path in the future
1171
+ initialOptions.rootDir = initialOptions.rootDir || packageRootOrConfig;
1172
+ return {
1173
+ config: initialOptions,
1174
+ configPath: null
1175
+ };
1176
+ } catch {
1177
+ throw new Error('There was an error while parsing the `--config` argument as a JSON string.');
1178
+ }
1179
+ }
1180
+ if (!readFromCwd && typeof config == 'string') {
1181
+ // A string passed to `--config`, which is either a direct path to the config
1182
+ // or a path to directory containing `package.json`, `jest.config.js` or `jest.config.ts`
1183
+ const configPath = (0, _resolveConfigPath.default)(config, process.cwd(), skipMultipleConfigError);
1184
+ return {
1185
+ config: await (0, _readConfigFileAndSetRootDir.default)(configPath),
1186
+ configPath
1187
+ };
1188
+ }
1189
+ // Otherwise just try to find config in the current rootDir.
1190
+ const configPath = (0, _resolveConfigPath.default)(packageRootOrConfig, process.cwd(), skipMultipleConfigError);
1191
+ return {
1192
+ config: await (0, _readConfigFileAndSetRootDir.default)(configPath),
1193
+ configPath
1194
+ };
1195
+ }
1196
+
1197
+ // Possible scenarios:
1198
+ // 1. jest --config config.json
1199
+ // 2. jest --projects p1 p2
1200
+ // 3. jest --projects p1 p2 --config config.json
1201
+ // 4. jest --projects p1
1202
+ // 5. jest
1203
+ //
1204
+ // If no projects are specified, process.cwd() will be used as the default
1205
+ // (and only) project.
1206
+ async function readConfigs(argv, projectPaths) {
1207
+ let globalConfig;
1208
+ let hasDeprecationWarnings;
1209
+ let configs = [];
1210
+ let projects = projectPaths;
1211
+ let configPath;
1212
+ if (projectPaths.length === 1) {
1213
+ const parsedConfig = await readConfig(argv, projects[0]);
1214
+ configPath = parsedConfig.configPath;
1215
+ hasDeprecationWarnings = parsedConfig.hasDeprecationWarnings;
1216
+ globalConfig = parsedConfig.globalConfig;
1217
+ configs = [parsedConfig.projectConfig];
1218
+ if (globalConfig.projects && globalConfig.projects.length > 0) {
1219
+ // Even though we had one project in CLI args, there might be more
1220
+ // projects defined in the config.
1221
+ // In other words, if this was a single project,
1222
+ // and its config has `projects` settings, use that value instead.
1223
+ projects = globalConfig.projects;
1224
+ }
1225
+ }
1226
+ if (projects.length > 0) {
1227
+ const cwd = process.platform === 'win32' ? (0, _jestUtil().tryRealpath)(process.cwd()) : process.cwd();
1228
+ const projectIsCwd = projects[0] === cwd;
1229
+ const parsedConfigs = await Promise.all(projects.filter(root => {
1230
+ // Ignore globbed files that cannot be `require`d.
1231
+ if (typeof root === 'string' && fs().existsSync(root) && !fs().lstatSync(root).isDirectory() && !constants.JEST_CONFIG_EXT_ORDER.some(ext => root.endsWith(ext))) {
1232
+ return false;
1233
+ }
1234
+ return true;
1235
+ }).map((root, projectIndex) => {
1236
+ const projectIsTheOnlyProject = projectIndex === 0 && projects.length === 1;
1237
+ const skipArgvConfigOption = !(projectIsTheOnlyProject && projectIsCwd);
1238
+ return readConfig(argv, root, skipArgvConfigOption, configPath ? path().dirname(configPath) : cwd, projectIndex,
1239
+ // we wanna skip the warning if this is the "main" project
1240
+ projectIsCwd);
1241
+ }));
1242
+ ensureNoDuplicateConfigs(parsedConfigs, projects);
1243
+ configs = parsedConfigs.map(({
1244
+ projectConfig
1245
+ }) => projectConfig);
1246
+ if (!hasDeprecationWarnings) {
1247
+ hasDeprecationWarnings = parsedConfigs.some(({
1248
+ hasDeprecationWarnings
1249
+ }) => !!hasDeprecationWarnings);
1250
+ }
1251
+ // If no config was passed initially, use the one from the first project
1252
+ if (!globalConfig) {
1253
+ globalConfig = parsedConfigs[0].globalConfig;
1254
+ }
1255
+ }
1256
+ if (!globalConfig || configs.length === 0) {
1257
+ throw new Error('jest: No configuration found for any project.');
1258
+ }
1259
+ return {
1260
+ configs,
1261
+ globalConfig,
1262
+ hasDeprecationWarnings: !!hasDeprecationWarnings
1263
+ };
1264
+ }
1265
+
1266
+ /***/ },
1267
+
1268
+ /***/ "./src/normalize.ts"
1269
+ (module, exports, __webpack_require__) {
1270
+
1271
+
1272
+
1273
+ Object.defineProperty(exports, "__esModule", ({
1274
+ value: true
1275
+ }));
1276
+ exports["default"] = normalize;
1277
+ function _nodeCrypto() {
1278
+ const data = require("node:crypto");
1279
+ _nodeCrypto = function () {
1280
+ return data;
1281
+ };
1282
+ return data;
1283
+ }
1284
+ function _nodeOs() {
1285
+ const data = require("node:os");
1286
+ _nodeOs = function () {
1287
+ return data;
1288
+ };
1289
+ return data;
1290
+ }
1291
+ function path() {
1292
+ const data = _interopRequireWildcard(require("node:path"));
1293
+ path = function () {
1294
+ return data;
1295
+ };
1296
+ return data;
1297
+ }
1298
+ function _chalk() {
1299
+ const data = _interopRequireDefault(require("chalk"));
1300
+ _chalk = function () {
1301
+ return data;
1302
+ };
1303
+ return data;
1304
+ }
1305
+ function _deepmerge() {
1306
+ const data = _interopRequireDefault(require("deepmerge"));
1307
+ _deepmerge = function () {
1308
+ return data;
1309
+ };
1310
+ return data;
1311
+ }
1312
+ function _glob() {
1313
+ const data = require("glob");
1314
+ _glob = function () {
1315
+ return data;
1316
+ };
1317
+ return data;
1318
+ }
1319
+ function _gracefulFs() {
1320
+ const data = require("graceful-fs");
1321
+ _gracefulFs = function () {
1322
+ return data;
1323
+ };
1324
+ return data;
1325
+ }
1326
+ function _jestPattern() {
1327
+ const data = require("@pkg-nec/jest-pattern");
1328
+ _jestPattern = function () {
1329
+ return data;
1330
+ };
1331
+ return data;
1332
+ }
1333
+ function _jestRegexUtil() {
1334
+ const data = require("@pkg-nec/jest-regex-util");
1335
+ _jestRegexUtil = function () {
1336
+ return data;
1337
+ };
1338
+ return data;
1339
+ }
1340
+ function _jestResolve() {
1341
+ const data = _interopRequireWildcard(require("@pkg-nec/jest-resolve"));
1342
+ _jestResolve = function () {
1343
+ return data;
1344
+ };
1345
+ return data;
1346
+ }
1347
+ function _jestUtil() {
1348
+ const data = require("@pkg-nec/jest-util");
1349
+ _jestUtil = function () {
1350
+ return data;
1351
+ };
1352
+ return data;
1353
+ }
1354
+ function _jestValidate() {
1355
+ const data = require("@pkg-nec/jest-validate");
1356
+ _jestValidate = function () {
1357
+ return data;
1358
+ };
1359
+ return data;
1360
+ }
1361
+ var _Defaults = _interopRequireDefault(__webpack_require__("./src/Defaults.ts"));
1362
+ var _Deprecated = _interopRequireDefault(__webpack_require__("./src/Deprecated.ts"));
1363
+ var _ReporterValidationErrors = __webpack_require__("./src/ReporterValidationErrors.ts");
1364
+ var _ValidConfig = __webpack_require__("./src/ValidConfig.ts");
1365
+ var _color = __webpack_require__("./src/color.ts");
1366
+ var _constants = __webpack_require__("./src/constants.ts");
1367
+ var _getMaxWorkers = _interopRequireDefault(__webpack_require__("./src/getMaxWorkers.ts"));
1368
+ var _parseShardPair = __webpack_require__("./src/parseShardPair.ts");
1369
+ var _setFromArgv = _interopRequireDefault(__webpack_require__("./src/setFromArgv.ts"));
1370
+ var _stringToBytes = _interopRequireDefault(__webpack_require__("./src/stringToBytes.ts"));
1371
+ var _utils = __webpack_require__("./src/utils.ts");
1372
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
1373
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
1374
+ /**
1375
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1376
+ *
1377
+ * This source code is licensed under the MIT license found in the
1378
+ * LICENSE file in the root directory of this source tree.
1379
+ */
1380
+
1381
+ const ERROR = `${_utils.BULLET}Validation Error`;
1382
+ const PRESET_EXTENSIONS = ['.json', '.js', '.cjs', '.mjs'];
1383
+ const PRESET_NAME = 'jest-preset';
1384
+ const GLOBAL_ONLY_OPTIONS = new Set(Object.keys(_ValidConfig.initialOptions).filter(key => !Object.hasOwn(_ValidConfig.initialProjectOptions, key)));
1385
+ const unknownProjectOption = (config, exampleConfig, option, options, path) => {
1386
+ const warningTitle = (options.title && options.title.warning) ?? 'Validation Warning';
1387
+ const optionPath = path && path.length > 0 ? `${path.join('.')}.` : '';
1388
+ if ((!path || path.length === 0) && GLOBAL_ONLY_OPTIONS.has(option)) {
1389
+ (0, _jestValidate().logValidationWarning)(warningTitle, ` Option ${_chalk().default.bold(`"${optionPath}${option}"`)} is not supported in an individual project configuration.\n Move it to the root configuration.`, options.comment);
1390
+ } else {
1391
+ const didYouMean = (0, _jestValidate().createDidYouMeanMessage)(option, Object.keys(exampleConfig));
1392
+ (0, _jestValidate().logValidationWarning)(warningTitle, ` Unknown option ${_chalk().default.bold(`"${optionPath}${option}"`)} with value ${_chalk().default.bold((0, _jestValidate().format)(config[option]))} was found.${didYouMean && ` ${didYouMean}`}\n This is probably a typing mistake. Fixing it will remove this message.`, options.comment);
1393
+ }
1394
+ };
1395
+ const createConfigError = message => new (_jestValidate().ValidationError)(ERROR, message, _utils.DOCUMENTATION_NOTE);
1396
+
1397
+ // we wanna avoid webpack trying to be clever
1398
+ const requireResolve = module => require.resolve(module);
1399
+ function verifyDirectoryExists(path, key) {
1400
+ try {
1401
+ const rootStat = (0, _gracefulFs().statSync)(path);
1402
+ if (!rootStat.isDirectory()) {
1403
+ throw createConfigError(` ${_chalk().default.bold(path)} in the ${_chalk().default.bold(key)} option is not a directory.`);
1404
+ }
1405
+ } catch (error) {
1406
+ if (error instanceof _jestValidate().ValidationError) {
1407
+ throw error;
1408
+ }
1409
+ if (error.code === 'ENOENT') {
1410
+ throw createConfigError(` Directory ${_chalk().default.bold(path)} in the ${_chalk().default.bold(key)} option was not found.`);
1411
+ }
1412
+
1413
+ // Not sure in which cases `statSync` can throw, so let's just show the underlying error to the user
1414
+ throw createConfigError(` Got an error trying to find ${_chalk().default.bold(path)} in the ${_chalk().default.bold(key)} option.\n\n Error was: ${error.message}`);
1415
+ }
1416
+ }
1417
+ const mergeOptionWithPreset = (options, preset, optionName) => {
1418
+ if (options[optionName] && preset[optionName]) {
1419
+ options[optionName] = {
1420
+ ...options[optionName],
1421
+ ...preset[optionName],
1422
+ ...options[optionName]
1423
+ };
1424
+ }
1425
+ };
1426
+ const mergeGlobalsWithPreset = (options, preset) => {
1427
+ if (options.globals && preset.globals) {
1428
+ options.globals = (0, _deepmerge().default)(preset.globals, options.globals);
1429
+ }
1430
+ };
1431
+ const setupPreset = async (options, optionsPreset) => {
1432
+ let preset;
1433
+ const presetPath = (0, _utils.replaceRootDirInPath)(options.rootDir, optionsPreset);
1434
+ const presetModule = _jestResolve().default.findNodeModule(presetPath.startsWith('.') || path().isAbsolute(presetPath) ? presetPath : `${presetPath}/${PRESET_NAME}`, {
1435
+ basedir: options.rootDir,
1436
+ extensions: PRESET_EXTENSIONS
1437
+ });
1438
+ try {
1439
+ if (!presetModule) {
1440
+ throw new Error(`Cannot find module '${presetPath}'`);
1441
+ }
1442
+
1443
+ // Force re-evaluation to support multiple projects
1444
+ try {
1445
+ delete __webpack_require__.c[require.resolve(presetModule)];
1446
+ } catch {}
1447
+ preset = await (0, _jestUtil().requireOrImportModule)(presetModule);
1448
+ } catch (error) {
1449
+ if (error instanceof SyntaxError || error instanceof TypeError) {
1450
+ throw createConfigError(` Preset ${_chalk().default.bold(presetPath)} is invalid:\n\n ${error.message}\n ${error.stack}`);
1451
+ }
1452
+ if (error.message.includes('Cannot find module')) {
1453
+ if (error.message.includes(presetPath)) {
1454
+ const preset = _jestResolve().default.findNodeModule(presetPath, {
1455
+ basedir: options.rootDir
1456
+ });
1457
+ if (preset) {
1458
+ throw createConfigError(` Module ${_chalk().default.bold(presetPath)} should have "jest-preset.js" or "jest-preset.json" file at the root.`);
1459
+ }
1460
+ throw createConfigError(` Preset ${_chalk().default.bold(presetPath)} not found relative to rootDir ${_chalk().default.bold(options.rootDir)}.`);
1461
+ }
1462
+ throw createConfigError(` Missing dependency in ${_chalk().default.bold(presetPath)}:\n\n ${error.message}\n ${error.stack}`);
1463
+ }
1464
+ throw createConfigError(` An unknown error occurred in ${_chalk().default.bold(presetPath)}:\n\n ${error.message}\n ${error.stack}`);
1465
+ }
1466
+ if (options.setupFiles) {
1467
+ options.setupFiles = [...(preset.setupFiles || []), ...options.setupFiles];
1468
+ }
1469
+ if (options.setupFilesAfterEnv) {
1470
+ options.setupFilesAfterEnv = [...(preset.setupFilesAfterEnv || []), ...options.setupFilesAfterEnv];
1471
+ }
1472
+ if (options.modulePathIgnorePatterns && preset.modulePathIgnorePatterns) {
1473
+ options.modulePathIgnorePatterns = [...preset.modulePathIgnorePatterns, ...options.modulePathIgnorePatterns];
1474
+ }
1475
+ mergeOptionWithPreset(options, preset, 'moduleNameMapper');
1476
+ mergeOptionWithPreset(options, preset, 'transform');
1477
+ mergeGlobalsWithPreset(options, preset);
1478
+ return {
1479
+ ...preset,
1480
+ ...options
1481
+ };
1482
+ };
1483
+ const setupBabelJest = options => {
1484
+ const transform = options.transform;
1485
+ let babelJest;
1486
+ if (transform) {
1487
+ const customJSPattern = Object.keys(transform).find(pattern => {
1488
+ const regex = new RegExp(pattern);
1489
+ return regex.test('a.js') || regex.test('a.jsx');
1490
+ });
1491
+ const customTSPattern = Object.keys(transform).find(pattern => {
1492
+ const regex = new RegExp(pattern);
1493
+ return regex.test('a.ts') || regex.test('a.tsx');
1494
+ });
1495
+ for (const pattern of [customJSPattern, customTSPattern]) {
1496
+ if (pattern) {
1497
+ const customTransformer = transform[pattern];
1498
+ if (Array.isArray(customTransformer)) {
1499
+ if (customTransformer[0] === 'babel-jest') {
1500
+ babelJest = require.resolve('@pkg-nec/babel-jest');
1501
+ customTransformer[0] = babelJest;
1502
+ } else if (customTransformer[0].includes('babel-jest')) {
1503
+ babelJest = customTransformer[0];
1504
+ }
1505
+ } else {
1506
+ if (customTransformer === 'babel-jest') {
1507
+ babelJest = require.resolve('@pkg-nec/babel-jest');
1508
+ transform[pattern] = babelJest;
1509
+ } else if (customTransformer.includes('babel-jest')) {
1510
+ babelJest = customTransformer;
1511
+ }
1512
+ }
1513
+ }
1514
+ }
1515
+ } else {
1516
+ babelJest = require.resolve('@pkg-nec/babel-jest');
1517
+ options.transform = {
1518
+ [_constants.DEFAULT_JS_PATTERN]: babelJest
1519
+ };
1520
+ }
1521
+ };
1522
+ const normalizeCollectCoverageFrom = (options, key) => {
1523
+ const initialCollectCoverageFrom = options[key];
1524
+ let value;
1525
+ if (!initialCollectCoverageFrom) {
1526
+ value = [];
1527
+ }
1528
+ if (Array.isArray(initialCollectCoverageFrom)) {
1529
+ value = initialCollectCoverageFrom;
1530
+ } else {
1531
+ try {
1532
+ value = JSON.parse(initialCollectCoverageFrom);
1533
+ } catch {}
1534
+ if (options[key] && !Array.isArray(value)) {
1535
+ value = [initialCollectCoverageFrom];
1536
+ }
1537
+ }
1538
+ if (value) {
1539
+ value = value.map(filePath => filePath.replace(/^(!?)(<rootDir>\/)(.*)/, '$1$3'));
1540
+ }
1541
+ return value;
1542
+ };
1543
+ const normalizeUnmockedModulePathPatterns = (options, key) =>
1544
+ // _replaceRootDirTags is specifically well-suited for substituting
1545
+ // <rootDir> in paths (it deals with properly interpreting relative path
1546
+ // separators, etc).
1547
+ //
1548
+ // For patterns, direct global substitution is far more ideal, so we
1549
+ // special case substitutions for patterns here.
1550
+ options[key].map(pattern => (0, _jestRegexUtil().replacePathSepForRegex)(pattern.replaceAll('<rootDir>', options.rootDir)));
1551
+ const normalizeMissingOptions = (options, configPath, projectIndex) => {
1552
+ if (!options.id) {
1553
+ options.id = (0, _nodeCrypto().createHash)('sha1').update(options.rootDir)
1554
+ // In case we load config from some path that has the same root dir
1555
+ .update(configPath || '').update(String(projectIndex)).digest('hex').slice(0, 32);
1556
+ }
1557
+ if (!options.setupFiles) {
1558
+ options.setupFiles = [];
1559
+ }
1560
+ return options;
1561
+ };
1562
+ const normalizeRootDir = options => {
1563
+ // Assert that there *is* a rootDir
1564
+ if (!options.rootDir) {
1565
+ throw createConfigError(` Configuration option ${_chalk().default.bold('rootDir')} must be specified.`);
1566
+ }
1567
+ options.rootDir = path().normalize(options.rootDir);
1568
+ try {
1569
+ // try to resolve windows short paths, ignoring errors (permission errors, mostly)
1570
+ options.rootDir = (0, _jestUtil().tryRealpath)(options.rootDir);
1571
+ } catch {
1572
+ // ignored
1573
+ }
1574
+ verifyDirectoryExists(options.rootDir, 'rootDir');
1575
+ return {
1576
+ ...options,
1577
+ rootDir: options.rootDir
1578
+ };
1579
+ };
1580
+ const normalizeReporters = ({
1581
+ reporters,
1582
+ rootDir
1583
+ }) => {
1584
+ if (!reporters || !Array.isArray(reporters)) {
1585
+ return undefined;
1586
+ }
1587
+ (0, _ReporterValidationErrors.validateReporters)(reporters);
1588
+ return reporters.map(reporterConfig => {
1589
+ const normalizedReporterConfig = typeof reporterConfig === 'string' ?
1590
+ // if reporter config is a string, we wrap it in an array
1591
+ // and pass an empty object for options argument, to normalize
1592
+ // the shape.
1593
+ [reporterConfig, {}] : reporterConfig;
1594
+ const reporterPath = (0, _utils.replaceRootDirInPath)(rootDir, normalizedReporterConfig[0]);
1595
+ if (!['agent', 'default', 'github-actions', 'summary'].includes(reporterPath)) {
1596
+ const reporter = _jestResolve().default.findNodeModule(reporterPath, {
1597
+ basedir: rootDir
1598
+ });
1599
+ if (!reporter) {
1600
+ throw new (_jestResolve().default.ModuleNotFoundError)('Could not resolve a module for a custom reporter.\n' + ` Module name: ${reporterPath}`);
1601
+ }
1602
+ normalizedReporterConfig[0] = reporter;
1603
+ }
1604
+ return normalizedReporterConfig;
1605
+ });
1606
+ };
1607
+ const buildTestPathPatterns = argv => {
1608
+ const patterns = [];
1609
+ if (argv._) {
1610
+ patterns.push(...argv._.map(x => x.toString()));
1611
+ }
1612
+ if (argv.testPathPatterns) {
1613
+ patterns.push(...argv.testPathPatterns);
1614
+ }
1615
+ const testPathPatterns = new (_jestPattern().TestPathPatterns)(patterns);
1616
+ if (!testPathPatterns.isValid()) {
1617
+ (0, _jestUtil().clearLine)(process.stdout);
1618
+
1619
+ // eslint-disable-next-line no-console
1620
+ console.log(_chalk().default.red(` Invalid testPattern ${testPathPatterns.toPretty()} supplied. ` + 'Running all tests instead.'));
1621
+ return new (_jestPattern().TestPathPatterns)([]);
1622
+ }
1623
+ return testPathPatterns;
1624
+ };
1625
+ function printConfig(opts) {
1626
+ const string = opts.map(ext => `'${ext}'`).join(', ');
1627
+ return _chalk().default.bold(`extensionsToTreatAsEsm: [${string}]`);
1628
+ }
1629
+ function validateExtensionsToTreatAsEsm(extensionsToTreatAsEsm) {
1630
+ if (!extensionsToTreatAsEsm || extensionsToTreatAsEsm.length === 0) {
1631
+ return;
1632
+ }
1633
+ const extensionWithoutDot = extensionsToTreatAsEsm.some(ext => !ext.startsWith('.'));
1634
+ if (extensionWithoutDot) {
1635
+ throw createConfigError(` Option: ${printConfig(extensionsToTreatAsEsm)} includes a string that does not start with a period (${_chalk().default.bold('.')}).
1636
+ Please change your configuration to ${printConfig(extensionsToTreatAsEsm.map(ext => ext.startsWith('.') ? ext : `.${ext}`))}.`);
1637
+ }
1638
+ if (extensionsToTreatAsEsm.includes('.js')) {
1639
+ throw createConfigError(` Option: ${printConfig(extensionsToTreatAsEsm)} includes ${_chalk().default.bold("'.js'")} which is always inferred based on ${_chalk().default.bold('type')} in its nearest ${_chalk().default.bold('package.json')}.`);
1640
+ }
1641
+ if (extensionsToTreatAsEsm.includes('.cjs')) {
1642
+ throw createConfigError(` Option: ${printConfig(extensionsToTreatAsEsm)} includes ${_chalk().default.bold("'.cjs'")} which is always treated as CommonJS.`);
1643
+ }
1644
+ if (extensionsToTreatAsEsm.includes('.mjs')) {
1645
+ throw createConfigError(` Option: ${printConfig(extensionsToTreatAsEsm)} includes ${_chalk().default.bold("'.mjs'")} which is always treated as an ECMAScript Module.`);
1646
+ }
1647
+ }
1648
+ async function normalize(initialOptions, argv, configPath, projectIndex = Number.POSITIVE_INFINITY, isProjectOptions) {
1649
+ const {
1650
+ hasDeprecationWarnings
1651
+ } = (0, _jestValidate().validate)(initialOptions, {
1652
+ comment: _utils.DOCUMENTATION_NOTE,
1653
+ deprecatedConfig: _Deprecated.default,
1654
+ exampleConfig: isProjectOptions ? _ValidConfig.initialProjectOptions : _ValidConfig.initialOptions,
1655
+ recursiveDenylist: [
1656
+ // 'coverageThreshold' allows to use 'global' and glob strings on the same
1657
+ // level, there's currently no way we can deal with such config
1658
+ 'coverageThreshold', 'globals', 'moduleNameMapper', 'testEnvironmentOptions', 'transform'],
1659
+ ...(isProjectOptions && {
1660
+ unknown: unknownProjectOption
1661
+ })
1662
+ });
1663
+ let options = normalizeMissingOptions(normalizeRootDir((0, _setFromArgv.default)(initialOptions, argv)), configPath, projectIndex);
1664
+ if (options.preset) {
1665
+ options = await setupPreset(options, options.preset);
1666
+ }
1667
+ if (!options.setupFilesAfterEnv) {
1668
+ options.setupFilesAfterEnv = [];
1669
+ }
1670
+ options.testEnvironment = (0, _jestResolve().resolveTestEnvironment)({
1671
+ requireResolveFunction: requireResolve,
1672
+ rootDir: options.rootDir,
1673
+ testEnvironment: options.testEnvironment || require.resolve(_Defaults.default.testEnvironment)
1674
+ });
1675
+ if (!options.roots) {
1676
+ options.roots = [options.rootDir];
1677
+ }
1678
+ if (!options.testRunner || options.testRunner === 'circus' || options.testRunner === 'jest-circus' || options.testRunner === 'jest-circus/runner') {
1679
+ options.testRunner = require.resolve('@pkg-nec/jest-circus/runner');
1680
+ } else if (options.testRunner === 'jasmine2') {
1681
+ try {
1682
+ options.testRunner = require.resolve('@pkg-nec/jest-jasmine2');
1683
+ } catch (error) {
1684
+ if (error.code === 'MODULE_NOT_FOUND') {
1685
+ throw createConfigError('jest-jasmine is no longer shipped by default with Jest, you need to install it explicitly or provide an absolute path to Jest');
1686
+ }
1687
+ throw error;
1688
+ }
1689
+ }
1690
+ if (!options.coverageDirectory) {
1691
+ options.coverageDirectory = path().resolve(options.rootDir, 'coverage');
1692
+ }
1693
+ setupBabelJest(options);
1694
+ // TODO: Type this properly
1695
+ const newOptions = {
1696
+ ..._Defaults.default
1697
+ };
1698
+ if (options.resolver) {
1699
+ newOptions.resolver = (0, _utils.resolve)(null, {
1700
+ filePath: options.resolver,
1701
+ key: 'resolver',
1702
+ rootDir: options.rootDir
1703
+ });
1704
+ }
1705
+ validateExtensionsToTreatAsEsm(options.extensionsToTreatAsEsm);
1706
+ if (options.watchman == null) {
1707
+ options.watchman = _Defaults.default.watchman;
1708
+ }
1709
+ const optionKeys = Object.keys(options);
1710
+ optionKeys.reduce((newOptions, key) => {
1711
+ // The resolver has been resolved separately; skip it
1712
+ if (key === 'resolver') {
1713
+ return newOptions;
1714
+ }
1715
+
1716
+ // This is cheating, because it claims that all keys of InitialOptions are Required.
1717
+ // We only really know it's Required for oldOptions[key], not for oldOptions.someOtherKey,
1718
+ // so oldOptions[key] is the only way it should be used.
1719
+ const oldOptions = options;
1720
+ let value;
1721
+ switch (key) {
1722
+ case 'setupFiles':
1723
+ case 'setupFilesAfterEnv':
1724
+ case 'snapshotSerializers':
1725
+ {
1726
+ const option = oldOptions[key];
1727
+ value = option && option.map(filePath => (0, _utils.resolve)(newOptions.resolver, {
1728
+ filePath,
1729
+ key,
1730
+ rootDir: options.rootDir
1731
+ }));
1732
+ break;
1733
+ }
1734
+ case 'modulePaths':
1735
+ case 'roots':
1736
+ {
1737
+ const option = oldOptions[key];
1738
+ value = option && option.map(filePath => path().resolve(options.rootDir, (0, _utils.replaceRootDirInPath)(options.rootDir, filePath)));
1739
+ break;
1740
+ }
1741
+ case 'collectCoverageFrom':
1742
+ value = normalizeCollectCoverageFrom(oldOptions, key);
1743
+ break;
1744
+ case 'cacheDirectory':
1745
+ case 'coverageDirectory':
1746
+ {
1747
+ const option = oldOptions[key];
1748
+ value = option && path().resolve(options.rootDir, (0, _utils.replaceRootDirInPath)(options.rootDir, option));
1749
+ break;
1750
+ }
1751
+ case 'dependencyExtractor':
1752
+ case 'globalSetup':
1753
+ case 'globalTeardown':
1754
+ case 'runtime':
1755
+ case 'snapshotResolver':
1756
+ case 'testResultsProcessor':
1757
+ case 'testRunner':
1758
+ case 'filter':
1759
+ {
1760
+ const option = oldOptions[key];
1761
+ value = option && (0, _utils.resolve)(newOptions.resolver, {
1762
+ filePath: option,
1763
+ key,
1764
+ rootDir: options.rootDir
1765
+ });
1766
+ break;
1767
+ }
1768
+ case 'runner':
1769
+ {
1770
+ const option = oldOptions[key];
1771
+ let runnerPath;
1772
+ if (Array.isArray(option)) {
1773
+ if (typeof option[0] !== 'string' || option[0].length === 0) {
1774
+ throw createConfigError(' Runner must be a string or a tuple [string, object].\n' + ' Configuration Documentation:\n' + ' https://jestjs.io/docs/configuration#runner-string--string-object');
1775
+ }
1776
+ runnerPath = option[0];
1777
+ const runnerOptions = option[1];
1778
+ if (runnerOptions != null && (typeof runnerOptions !== 'object' || Array.isArray(runnerOptions) || Object.getPrototypeOf(runnerOptions) !== Object.prototype)) {
1779
+ throw createConfigError(' Runner options must be a plain object.\n' + ' Configuration Documentation:\n' + ' https://jestjs.io/docs/configuration#runner-string--string-object');
1780
+ }
1781
+ newOptions.runnerOptions = runnerOptions ?? {};
1782
+ } else {
1783
+ runnerPath = option;
1784
+ newOptions.runnerOptions = {};
1785
+ }
1786
+ value = runnerPath && (0, _jestResolve().resolveRunner)(newOptions.resolver, {
1787
+ filePath: runnerPath,
1788
+ requireResolveFunction: requireResolve,
1789
+ rootDir: options.rootDir
1790
+ });
1791
+ break;
1792
+ }
1793
+ case 'prettierPath':
1794
+ {
1795
+ // We only want this to throw if "prettierPath" is explicitly passed
1796
+ // from config or CLI, and the requested path isn't found. Otherwise we
1797
+ // set it to null and throw an error lazily when it is used.
1798
+
1799
+ const option = oldOptions[key];
1800
+ value = option && (0, _utils.resolve)(newOptions.resolver, {
1801
+ filePath: option,
1802
+ key,
1803
+ optional: option === _Defaults.default[key],
1804
+ rootDir: options.rootDir
1805
+ });
1806
+ break;
1807
+ }
1808
+ case 'moduleNameMapper':
1809
+ const moduleNameMapper = oldOptions[key];
1810
+ value = moduleNameMapper && Object.keys(moduleNameMapper).map(regex => {
1811
+ const item = moduleNameMapper && moduleNameMapper[regex];
1812
+ return item && [regex, (0, _utils._replaceRootDirTags)(options.rootDir, item)];
1813
+ });
1814
+ break;
1815
+ case 'transform':
1816
+ const transform = oldOptions[key];
1817
+ value = transform && Object.keys(transform).map(regex => {
1818
+ const transformElement = transform[regex];
1819
+ return [regex, (0, _utils.resolve)(newOptions.resolver, {
1820
+ filePath: Array.isArray(transformElement) ? transformElement[0] : transformElement,
1821
+ key,
1822
+ rootDir: options.rootDir
1823
+ }), Array.isArray(transformElement) ? transformElement[1] : {}];
1824
+ });
1825
+ break;
1826
+ case 'reporters':
1827
+ value = normalizeReporters(oldOptions);
1828
+ break;
1829
+ case 'coveragePathIgnorePatterns':
1830
+ case 'modulePathIgnorePatterns':
1831
+ case 'testPathIgnorePatterns':
1832
+ case 'transformIgnorePatterns':
1833
+ case 'watchPathIgnorePatterns':
1834
+ case 'unmockedModulePathPatterns':
1835
+ value = normalizeUnmockedModulePathPatterns(oldOptions, key);
1836
+ break;
1837
+ case 'haste':
1838
+ value = {
1839
+ ...oldOptions[key]
1840
+ };
1841
+ if (value.hasteImplModulePath != null) {
1842
+ const resolvedHasteImpl = (0, _utils.resolve)(newOptions.resolver, {
1843
+ filePath: (0, _utils.replaceRootDirInPath)(options.rootDir, value.hasteImplModulePath),
1844
+ key: 'haste.hasteImplModulePath',
1845
+ rootDir: options.rootDir
1846
+ });
1847
+ value.hasteImplModulePath = resolvedHasteImpl || undefined;
1848
+ }
1849
+ break;
1850
+ case 'projects':
1851
+ value = (oldOptions[key] || []).map(project => typeof project === 'string' ? (0, _utils._replaceRootDirTags)(options.rootDir, project) : project).reduce((projects, project) => {
1852
+ // Project can be specified as globs. If a glob matches any files,
1853
+ // We expand it to these paths. If not, we keep the original path
1854
+ // for the future resolution.
1855
+ const globMatches = typeof project === 'string' ? _glob().glob.sync(project, {
1856
+ windowsPathsNoEscape: true
1857
+ }) : [];
1858
+ const projectEntry = globMatches.length > 0 ? globMatches : project;
1859
+ return [...projects, ...(Array.isArray(projectEntry) ? projectEntry : [projectEntry])];
1860
+ }, []);
1861
+ break;
1862
+ case 'moduleDirectories':
1863
+ case 'testMatch':
1864
+ {
1865
+ const option = oldOptions[key];
1866
+ const rawValue = Array.isArray(option) || option == null ? option : [option];
1867
+ const replacedRootDirTags = (0, _utils._replaceRootDirTags)((0, _utils.escapeGlobCharacters)(options.rootDir), rawValue);
1868
+ if (replacedRootDirTags) {
1869
+ value = Array.isArray(replacedRootDirTags) ? replacedRootDirTags.map(_jestUtil().replacePathSepForGlob) : (0, _jestUtil().replacePathSepForGlob)(replacedRootDirTags);
1870
+ } else {
1871
+ value = replacedRootDirTags;
1872
+ }
1873
+ break;
1874
+ }
1875
+ case 'testRegex':
1876
+ {
1877
+ const option = oldOptions[key];
1878
+ value = option ? (Array.isArray(option) ? option : [option]).map(_jestRegexUtil().replacePathSepForRegex) : [];
1879
+ break;
1880
+ }
1881
+ case 'moduleFileExtensions':
1882
+ {
1883
+ value = oldOptions[key];
1884
+ if (Array.isArray(value) && (
1885
+ // If it's the wrong type, it can throw at a later time
1886
+ options.runner === undefined || options.runner === _Defaults.default.runner) &&
1887
+ // Only require 'js' for the default jest-runner
1888
+ !value.includes('js')) {
1889
+ const errorMessage = " moduleFileExtensions must include 'js':\n" + ' but instead received:\n' + ` ${_chalk().default.bold.red(JSON.stringify(value))}`;
1890
+
1891
+ // If `js` is not included, any dependency Jest itself injects into
1892
+ // the environment, like jasmine or sourcemap-support, will need to
1893
+ // `require` its modules with a file extension. This is not plausible
1894
+ // in the long run, so it's way easier to just fail hard early.
1895
+ // We might consider throwing if `json` is missing as well, as it's a
1896
+ // fair assumption from modules that they can do
1897
+ // `require('some-package/package') without the trailing `.json` as it
1898
+ // works in Node normally.
1899
+ throw createConfigError(`${errorMessage}\n Please change your configuration to include 'js'.`);
1900
+ }
1901
+ break;
1902
+ }
1903
+ case 'bail':
1904
+ {
1905
+ const bail = oldOptions[key];
1906
+ if (typeof bail === 'boolean') {
1907
+ value = bail ? 1 : 0;
1908
+ } else if (typeof bail === 'string') {
1909
+ value = 1;
1910
+ // If Jest is invoked as `jest --bail someTestPattern` then need to
1911
+ // move the pattern from the `bail` configuration and into `argv._`
1912
+ // to be processed as an extra parameter
1913
+ argv._.push(bail);
1914
+ } else {
1915
+ value = oldOptions[key];
1916
+ }
1917
+ break;
1918
+ }
1919
+ case 'displayName':
1920
+ {
1921
+ const displayName = oldOptions[key];
1922
+ /**
1923
+ * Ensuring that displayName shape is correct here so that the
1924
+ * reporters can trust the shape of the data
1925
+ */
1926
+ if (typeof displayName === 'object') {
1927
+ const {
1928
+ name,
1929
+ color
1930
+ } = displayName;
1931
+ if (!name || !color || typeof name !== 'string' || typeof color !== 'string') {
1932
+ const errorMessage = ` Option "${_chalk().default.bold('displayName')}" must be of type:\n\n` + ' {\n' + ' name: string;\n' + ' color: string;\n' + ' }\n';
1933
+ throw createConfigError(errorMessage);
1934
+ }
1935
+ value = oldOptions[key];
1936
+ } else {
1937
+ value = {
1938
+ color: (0, _color.getDisplayNameColor)(Array.isArray(options.runner) ? options.runner[0] : options.runner),
1939
+ name: displayName
1940
+ };
1941
+ }
1942
+ break;
1943
+ }
1944
+ case 'testTimeout':
1945
+ {
1946
+ if (oldOptions[key] < 0) {
1947
+ throw createConfigError(` Option "${_chalk().default.bold('testTimeout')}" must be a natural number.`);
1948
+ }
1949
+ value = oldOptions[key];
1950
+ break;
1951
+ }
1952
+ case 'snapshotFormat':
1953
+ {
1954
+ value = {
1955
+ ..._Defaults.default.snapshotFormat,
1956
+ ...oldOptions[key]
1957
+ };
1958
+ break;
1959
+ }
1960
+ case 'automock':
1961
+ case 'cache':
1962
+ case 'changedSince':
1963
+ case 'changedFilesWithAncestor':
1964
+ case 'clearMocks':
1965
+ case 'collectCoverage':
1966
+ case 'coverageProvider':
1967
+ case 'coverageReporters':
1968
+ case 'coverageThreshold':
1969
+ case 'detectLeaks':
1970
+ case 'detectOpenHandles':
1971
+ case 'errorOnDeprecated':
1972
+ case 'expand':
1973
+ case 'extensionsToTreatAsEsm':
1974
+ case 'globals':
1975
+ case 'fakeTimers':
1976
+ case 'findRelatedTests':
1977
+ case 'forceCoverageMatch':
1978
+ case 'forceExit':
1979
+ case 'injectGlobals':
1980
+ case 'lastCommit':
1981
+ case 'listTests':
1982
+ case 'logHeapUsage':
1983
+ case 'maxConcurrency':
1984
+ case 'id':
1985
+ case 'noStackTrace':
1986
+ case 'notify':
1987
+ case 'notifyMode':
1988
+ case 'onlyChanged':
1989
+ case 'onlyFailures':
1990
+ case 'openHandlesTimeout':
1991
+ case 'outputFile':
1992
+ case 'passWithNoTests':
1993
+ case 'randomize':
1994
+ case 'replname':
1995
+ case 'resetMocks':
1996
+ case 'resetModules':
1997
+ case 'restoreMocks':
1998
+ case 'rootDir':
1999
+ case 'runTestsByPath':
2000
+ case 'sandboxInjectedGlobals':
2001
+ case 'silent':
2002
+ case 'showSeed':
2003
+ case 'skipFilter':
2004
+ case 'skipNodeResolution':
2005
+ case 'slowTestThreshold':
2006
+ case 'testEnvironment':
2007
+ case 'testEnvironmentOptions':
2008
+ case 'testFailureExitCode':
2009
+ case 'testLocationInResults':
2010
+ case 'testNamePattern':
2011
+ case 'useStderr':
2012
+ case 'verbose':
2013
+ case 'waitForUnhandledRejections':
2014
+ case 'watch':
2015
+ case 'watchAll':
2016
+ case 'watchman':
2017
+ case 'workerGracefulExitTimeout':
2018
+ case 'workerThreads':
2019
+ value = oldOptions[key];
2020
+ break;
2021
+ case 'workerIdleMemoryLimit':
2022
+ value = (0, _stringToBytes.default)(oldOptions[key], (0, _nodeOs().totalmem)());
2023
+ break;
2024
+ case 'watchPlugins':
2025
+ value = (oldOptions[key] || []).map(watchPlugin => {
2026
+ if (typeof watchPlugin === 'string') {
2027
+ return {
2028
+ config: {},
2029
+ path: (0, _jestResolve().resolveWatchPlugin)(newOptions.resolver, {
2030
+ filePath: watchPlugin,
2031
+ requireResolveFunction: requireResolve,
2032
+ rootDir: options.rootDir
2033
+ })
2034
+ };
2035
+ } else {
2036
+ return {
2037
+ config: watchPlugin[1] || {},
2038
+ path: (0, _jestResolve().resolveWatchPlugin)(newOptions.resolver, {
2039
+ filePath: watchPlugin[0],
2040
+ requireResolveFunction: requireResolve,
2041
+ rootDir: options.rootDir
2042
+ })
2043
+ };
2044
+ }
2045
+ });
2046
+ break;
2047
+ }
2048
+ // @ts-expect-error: automock is missing in GlobalConfig, so what
2049
+ newOptions[key] = value;
2050
+ return newOptions;
2051
+ }, newOptions);
2052
+ if (options.watchman && options.haste?.enableSymlinks) {
2053
+ throw new (_jestValidate().ValidationError)('Validation Error', 'haste.enableSymlinks is incompatible with watchman', 'Either set haste.enableSymlinks to false or do not use watchman');
2054
+ }
2055
+ for (const [i, root] of newOptions.roots.entries()) {
2056
+ verifyDirectoryExists(root, `roots[${i}]`);
2057
+ }
2058
+ try {
2059
+ // try to resolve windows short paths, ignoring errors (permission errors, mostly)
2060
+ newOptions.cwd = (0, _jestUtil().tryRealpath)(process.cwd());
2061
+ } catch {
2062
+ // ignored
2063
+ }
2064
+ newOptions.testSequencer = (0, _jestResolve().resolveSequencer)(newOptions.resolver, {
2065
+ filePath: options.testSequencer || require.resolve(_Defaults.default.testSequencer),
2066
+ requireResolveFunction: requireResolve,
2067
+ rootDir: options.rootDir
2068
+ });
2069
+ if (newOptions.runner === _Defaults.default.runner) {
2070
+ newOptions.runner = require.resolve(newOptions.runner);
2071
+ }
2072
+ if (newOptions.runnerOptions == null) {
2073
+ newOptions.runnerOptions = {};
2074
+ }
2075
+ newOptions.nonFlagArgs = argv._?.map(arg => `${arg}`);
2076
+ const testPathPatterns = buildTestPathPatterns(argv);
2077
+ newOptions.testPathPatterns = testPathPatterns;
2078
+ newOptions.json = !!argv.json;
2079
+ newOptions.testFailureExitCode = Number.parseInt(newOptions.testFailureExitCode, 10);
2080
+ if (newOptions.lastCommit || newOptions.changedFilesWithAncestor || newOptions.changedSince) {
2081
+ newOptions.onlyChanged = true;
2082
+ }
2083
+ if (argv.all) {
2084
+ newOptions.onlyChanged = false;
2085
+ newOptions.onlyFailures = false;
2086
+ } else if (testPathPatterns.isSet()) {
2087
+ // When passing a test path pattern we don't want to only monitor changed
2088
+ // files unless `--watch` is also passed.
2089
+ newOptions.onlyChanged = newOptions.watch;
2090
+ }
2091
+ newOptions.randomize = newOptions.randomize || argv.randomize;
2092
+ newOptions.showSeed = newOptions.randomize || newOptions.showSeed || argv.showSeed;
2093
+ const upperBoundSeedValue = 2 ** 31;
2094
+
2095
+ // bounds are determined by xoroshiro128plus which is used in v8 and is used here (at time of writing)
2096
+ newOptions.seed = argv.seed ?? Math.floor((2 ** 32 - 1) * Math.random() - upperBoundSeedValue);
2097
+ if (newOptions.seed < -upperBoundSeedValue || newOptions.seed > upperBoundSeedValue - 1) {
2098
+ throw new (_jestValidate().ValidationError)('Validation Error', `seed value must be between \`-0x80000000\` and \`0x7fffffff\` inclusive - instead it is ${newOptions.seed}`);
2099
+ }
2100
+ if (!newOptions.onlyChanged) {
2101
+ newOptions.onlyChanged = false;
2102
+ }
2103
+ if (!newOptions.lastCommit) {
2104
+ newOptions.lastCommit = false;
2105
+ }
2106
+ if (!newOptions.onlyFailures) {
2107
+ newOptions.onlyFailures = false;
2108
+ }
2109
+ if (!newOptions.watchAll) {
2110
+ newOptions.watchAll = false;
2111
+ }
2112
+
2113
+ // as unknown since it can happen. We really need to fix the types here
2114
+ if (newOptions.moduleNameMapper === _Defaults.default.moduleNameMapper) {
2115
+ newOptions.moduleNameMapper = [];
2116
+ }
2117
+ if (argv.ci != null) {
2118
+ newOptions.ci = argv.ci;
2119
+ }
2120
+ newOptions.updateSnapshot = newOptions.ci && !argv.updateSnapshot ? 'none' : argv.updateSnapshot ? 'all' : 'new';
2121
+ newOptions.collectTests = argv.collectTests || false;
2122
+ newOptions.maxConcurrency = Number.parseInt(newOptions.maxConcurrency, 10);
2123
+ newOptions.maxWorkers = (0, _getMaxWorkers.default)(argv, options);
2124
+ newOptions.runInBand = argv.runInBand || false;
2125
+ if (newOptions.testRegex.length > 0 && options.testMatch) {
2126
+ throw createConfigError(` Configuration options ${_chalk().default.bold('testMatch')} and` + ` ${_chalk().default.bold('testRegex')} cannot be used together.`);
2127
+ }
2128
+ if (newOptions.testRegex.length > 0 && !options.testMatch) {
2129
+ // Prevent the default testMatch conflicting with any explicitly
2130
+ // configured `testRegex` value
2131
+ newOptions.testMatch = [];
2132
+ }
2133
+
2134
+ // If argv.json is set without an outputFile, coverageReporters shouldn't print
2135
+ // a text report to avoid polluting the JSON written to stdout.
2136
+ if (argv.json && !argv.outputFile) {
2137
+ newOptions.coverageReporters = (newOptions.coverageReporters || []).filter(reporter => reporter !== 'text');
2138
+ }
2139
+
2140
+ // If collectCoverage is enabled while using --findRelatedTests we need to
2141
+ // avoid having false negatives in the generated coverage report.
2142
+ // The following: `--findRelatedTests '/rootDir/file1.js' --coverage`
2143
+ // Is transformed to: `--findRelatedTests '/rootDir/file1.js' --coverage --collectCoverageFrom 'file1.js'`
2144
+ // where arguments to `--collectCoverageFrom` should be globs (or relative
2145
+ // paths to the rootDir)
2146
+ if (newOptions.collectCoverage && argv.findRelatedTests) {
2147
+ let collectCoverageFrom = newOptions.nonFlagArgs.map(filename => {
2148
+ filename = (0, _utils.replaceRootDirInPath)(options.rootDir, filename);
2149
+ return path().isAbsolute(filename) ? path().relative(options.rootDir, filename) : filename;
2150
+ });
2151
+
2152
+ // Don't override existing collectCoverageFrom options
2153
+ if (newOptions.collectCoverageFrom) {
2154
+ collectCoverageFrom = collectCoverageFrom.reduce((patterns, filename) => {
2155
+ if (!(0, _jestUtil().globsToMatcher)(newOptions.collectCoverageFrom)((0, _jestUtil().replacePathSepForGlob)(path().relative(options.rootDir, filename)))) {
2156
+ return patterns;
2157
+ }
2158
+ return [...patterns, filename];
2159
+ }, newOptions.collectCoverageFrom);
2160
+ }
2161
+ newOptions.collectCoverageFrom = collectCoverageFrom;
2162
+ } else if (!newOptions.collectCoverageFrom) {
2163
+ newOptions.collectCoverageFrom = [];
2164
+ }
2165
+ if (!newOptions.findRelatedTests) {
2166
+ newOptions.findRelatedTests = false;
2167
+ }
2168
+ if (!newOptions.projects) {
2169
+ newOptions.projects = [];
2170
+ }
2171
+ if (!newOptions.sandboxInjectedGlobals) {
2172
+ newOptions.sandboxInjectedGlobals = [];
2173
+ }
2174
+ if (!newOptions.forceExit) {
2175
+ newOptions.forceExit = false;
2176
+ }
2177
+ if (!newOptions.logHeapUsage) {
2178
+ newOptions.logHeapUsage = false;
2179
+ }
2180
+ if (argv.shard) {
2181
+ newOptions.shard = (0, _parseShardPair.parseShardPair)(argv.shard);
2182
+ }
2183
+ return {
2184
+ hasDeprecationWarnings,
2185
+ options: newOptions
2186
+ };
2187
+ }
2188
+
2189
+ /***/ },
2190
+
2191
+ /***/ "./src/parseShardPair.ts"
2192
+ (__unused_webpack_module, exports) {
2193
+
2194
+
2195
+
2196
+ Object.defineProperty(exports, "__esModule", ({
2197
+ value: true
2198
+ }));
2199
+ exports.parseShardPair = void 0;
2200
+ /**
2201
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2202
+ *
2203
+ * This source code is licensed under the MIT license found in the
2204
+ * LICENSE file in the root directory of this source tree.
2205
+ */
2206
+
2207
+ const parseShardPair = pair => {
2208
+ const shardPair = pair.split('/').filter(d => /^\d+$/.test(d)).map(d => Number.parseInt(d, 10));
2209
+ const [shardIndex, shardCount] = shardPair;
2210
+ if (shardPair.length !== 2) {
2211
+ throw new Error('The shard option requires a string in the format of <n>/<m>.');
2212
+ }
2213
+ if (shardIndex === 0 || shardCount === 0) {
2214
+ throw new Error('The shard option requires 1-based values, received 0 or lower in the pair.');
2215
+ }
2216
+ if (shardIndex > shardCount) {
2217
+ throw new Error('The shard option <n>/<m> requires <n> to be lower or equal than <m>.');
2218
+ }
2219
+ return {
2220
+ shardCount,
2221
+ shardIndex
2222
+ };
2223
+ };
2224
+ exports.parseShardPair = parseShardPair;
2225
+
2226
+ /***/ },
2227
+
2228
+ /***/ "./src/readConfigFileAndSetRootDir.ts"
2229
+ (__unused_webpack_module, exports, __webpack_require__) {
2230
+
2231
+
2232
+
2233
+ Object.defineProperty(exports, "__esModule", ({
2234
+ value: true
2235
+ }));
2236
+ exports["default"] = readConfigFileAndSetRootDir;
2237
+ function path() {
2238
+ const data = _interopRequireWildcard(require("node:path"));
2239
+ path = function () {
2240
+ return data;
2241
+ };
2242
+ return data;
2243
+ }
2244
+ function fs() {
2245
+ const data = _interopRequireWildcard(require("graceful-fs"));
2246
+ fs = function () {
2247
+ return data;
2248
+ };
2249
+ return data;
2250
+ }
2251
+ function _parseJson() {
2252
+ const data = _interopRequireDefault(require("parse-json"));
2253
+ _parseJson = function () {
2254
+ return data;
2255
+ };
2256
+ return data;
2257
+ }
2258
+ function _stripJsonComments() {
2259
+ const data = _interopRequireDefault(require("strip-json-comments"));
2260
+ _stripJsonComments = function () {
2261
+ return data;
2262
+ };
2263
+ return data;
2264
+ }
2265
+ function _jestDocblock() {
2266
+ const data = require("@pkg-nec/jest-docblock");
2267
+ _jestDocblock = function () {
2268
+ return data;
2269
+ };
2270
+ return data;
2271
+ }
2272
+ function _jestUtil() {
2273
+ const data = require("@pkg-nec/jest-util");
2274
+ _jestUtil = function () {
2275
+ return data;
2276
+ };
2277
+ return data;
2278
+ }
2279
+ var _constants = __webpack_require__("./src/constants.ts");
2280
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
2281
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
2282
+ /**
2283
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2284
+ *
2285
+ * This source code is licensed under the MIT license found in the
2286
+ * LICENSE file in the root directory of this source tree.
2287
+ */
2288
+
2289
+ // Read the configuration and set its `rootDir`
2290
+ // 1. If it's a `package.json` file, we look into its "jest" property
2291
+ // 2. If it's a `jest.config.ts`/`jest.config.cts`/`jest.config.mts` file,
2292
+ // we use native TypeScript support when possible, otherwise a TS loader.
2293
+ // 3. For any other file, we just require it. If we receive an 'ERR_REQUIRE_ESM'
2294
+ // from node, perform a dynamic import instead.
2295
+ async function readConfigFileAndSetRootDir(configPath) {
2296
+ const isTS = configPath.endsWith(_constants.JEST_CONFIG_EXT_TS) || configPath.endsWith(_constants.JEST_CONFIG_EXT_MTS) || configPath.endsWith(_constants.JEST_CONFIG_EXT_CTS);
2297
+ const isMTS = configPath.endsWith(_constants.JEST_CONFIG_EXT_MTS);
2298
+ const isJSON = configPath.endsWith(_constants.JEST_CONFIG_EXT_JSON);
2299
+ let configObject;
2300
+ try {
2301
+ if (isTS) {
2302
+ // .mts is always ESM, so attempt import-based loading first.
2303
+ // @ts-expect-error: Type assertion can be removed once @types/node is updated to 23 https://nodejs.org/api/process.html#processfeaturestypescript
2304
+ if (isMTS || process.features.typescript) {
2305
+ try {
2306
+ // Try native node TypeScript support first.
2307
+ configObject = await (0, _jestUtil().requireOrImportModule)(configPath);
2308
+ } catch (requireOrImportModuleError) {
2309
+ if (isMTS) {
2310
+ // .mts is always ESM and cannot be loaded via require()/ts-node.
2311
+ throw new Error('jest.config.mts requires native TypeScript support. Ensure you are using Node.js 22.18+ or 23.6+.', {
2312
+ cause: requireOrImportModuleError
2313
+ });
2314
+ }
2315
+ if (!(requireOrImportModuleError instanceof SyntaxError)) {
2316
+ if (!hasTsLoaderExplicitlyConfigured(configPath)) {
2317
+ throw requireOrImportModuleError;
2318
+ }
2319
+ }
2320
+ try {
2321
+ // There are various reasons of failed loadout of Jest config in Typescript:
2322
+ // 1. User has specified a TypeScript loader in the docblock and
2323
+ // desire non-native compilation (https://github.com/jestjs/jest/issues/15837)
2324
+ // 2. Likely ESM in a file interpreted as CJS, which means it needs to be
2325
+ // compiled. We ignore the error and try to load it with a loader.
2326
+ configObject = await loadTSConfigFile(configPath);
2327
+ } catch (loadTSConfigFileError) {
2328
+ // If we still encounter an error, we throw both messages combined.
2329
+ // This string is caught further down and merged into a new error message.
2330
+ // eslint-disable-next-line no-throw-literal
2331
+ throw (
2332
+ // Preamble text is added further down:
2333
+ // Jest: Failed to parse the TypeScript config file ${configPath}\n
2334
+ ' both with the native node TypeScript support and configured TypeScript loaders.\n' + ' Errors were:\n' + ` - ${requireOrImportModuleError}\n` + ` - ${loadTSConfigFileError}`
2335
+ );
2336
+ }
2337
+ }
2338
+ } else {
2339
+ configObject = await loadTSConfigFile(configPath);
2340
+ }
2341
+ } else if (isJSON) {
2342
+ const fileContent = fs().readFileSync(configPath, 'utf8');
2343
+ configObject = (0, _parseJson().default)((0, _stripJsonComments().default)(fileContent), configPath);
2344
+ } else {
2345
+ configObject = await (0, _jestUtil().requireOrImportModule)(configPath);
2346
+ }
2347
+ } catch (error) {
2348
+ if (isTS) {
2349
+ throw new Error(`Jest: Failed to parse the TypeScript config file ${configPath}\n` + ` ${error}`);
2350
+ }
2351
+ throw error;
2352
+ }
2353
+ if (configPath.endsWith(_constants.PACKAGE_JSON)) {
2354
+ // Event if there's no "jest" property in package.json we will still use
2355
+ // an empty object.
2356
+ configObject = configObject.jest || {};
2357
+ }
2358
+ if (typeof configObject === 'function') {
2359
+ configObject = await configObject();
2360
+ }
2361
+ if (configObject.rootDir) {
2362
+ // We don't touch it if it has an absolute path specified
2363
+ if (!path().isAbsolute(configObject.rootDir)) {
2364
+ // otherwise, we'll resolve it relative to the file's __dirname
2365
+ configObject = {
2366
+ ...configObject,
2367
+ rootDir: path().resolve(path().dirname(configPath), configObject.rootDir)
2368
+ };
2369
+ }
2370
+ } else {
2371
+ // If rootDir is not there, we'll set it to this file's __dirname
2372
+ configObject = {
2373
+ ...configObject,
2374
+ rootDir: path().dirname(configPath)
2375
+ };
2376
+ }
2377
+ return configObject;
2378
+ }
2379
+
2380
+ // Load the TypeScript configuration
2381
+ let extraTSLoaderOptions;
2382
+ const hasTsLoaderExplicitlyConfigured = configPath => {
2383
+ const docblockPragmas = loadDocblockPragmasInConfig(configPath);
2384
+ const tsLoader = docblockPragmas['jest-config-loader'];
2385
+ return !Array.isArray(tsLoader) && (tsLoader ?? '').trim() !== '';
2386
+ };
2387
+ const loadDocblockPragmasInConfig = configPath => {
2388
+ const docblockPragmas = (0, _jestDocblock().parse)((0, _jestDocblock().extract)(fs().readFileSync(configPath, 'utf8')));
2389
+ return docblockPragmas;
2390
+ };
2391
+ const loadTSConfigFile = async configPath => {
2392
+ // Get registered TypeScript compiler instance
2393
+ const docblockPragmas = loadDocblockPragmasInConfig(configPath);
2394
+ const tsLoader = docblockPragmas['jest-config-loader'] || 'ts-node';
2395
+ const docblockTSLoaderOptions = docblockPragmas['jest-config-loader-options'];
2396
+ if (typeof docblockTSLoaderOptions === 'string') {
2397
+ extraTSLoaderOptions = JSON.parse(docblockTSLoaderOptions);
2398
+ }
2399
+ if (Array.isArray(tsLoader)) {
2400
+ throw new TypeError(`Jest: You can only define a single loader through docblocks, got "${tsLoader.join(', ')}"`);
2401
+ }
2402
+ const registeredCompiler = await getRegisteredCompiler(tsLoader);
2403
+ registeredCompiler.enabled(true);
2404
+ let configObject = (0, _jestUtil().interopRequireDefault)(require(configPath)).default;
2405
+
2406
+ // In case the config is a function which imports more Typescript code
2407
+ if (typeof configObject === 'function') {
2408
+ configObject = await configObject();
2409
+ }
2410
+ registeredCompiler.enabled(false);
2411
+ return configObject;
2412
+ };
2413
+ let registeredCompilerPromise;
2414
+ function getRegisteredCompiler(loader) {
2415
+ // Cache the promise to avoid multiple registrations
2416
+ registeredCompilerPromise = registeredCompilerPromise ?? registerTsLoader(loader);
2417
+ return registeredCompilerPromise;
2418
+ }
2419
+ async function registerTsLoader(loader) {
2420
+ try {
2421
+ // Register TypeScript compiler instance
2422
+ if (loader === 'ts-node') {
2423
+ const tsLoader = await import(/* webpackIgnore: true */'ts-node');
2424
+ return tsLoader.register({
2425
+ compilerOptions: {
2426
+ module: 'CommonJS'
2427
+ },
2428
+ moduleTypes: {
2429
+ '**': 'cjs'
2430
+ },
2431
+ ...extraTSLoaderOptions
2432
+ });
2433
+ } else if (loader === 'esbuild-register') {
2434
+ const tsLoader = await import(/* webpackIgnore: true */'esbuild-register/dist/node');
2435
+ let instance;
2436
+ return {
2437
+ enabled: bool => {
2438
+ if (bool) {
2439
+ instance = tsLoader.register({
2440
+ target: `node${process.version.slice(1)}`,
2441
+ ...extraTSLoaderOptions
2442
+ });
2443
+ } else {
2444
+ instance?.unregister();
2445
+ }
2446
+ }
2447
+ };
2448
+ }
2449
+ throw new Error(`Jest: '${loader}' is not a valid TypeScript configuration loader.`);
2450
+ } catch (error) {
2451
+ if ((0, _jestUtil().isError)(error) && error.code === 'ERR_MODULE_NOT_FOUND') {
2452
+ throw new Error(`Jest: '${loader}' is required for the TypeScript configuration files. Make sure it is installed\nError: ${error.message}`, {
2453
+ cause: error
2454
+ });
2455
+ }
2456
+ throw error;
2457
+ }
2458
+ }
2459
+
2460
+ /***/ },
2461
+
2462
+ /***/ "./src/resolveConfigPath.ts"
2463
+ (__unused_webpack_module, exports, __webpack_require__) {
2464
+
2465
+
2466
+
2467
+ Object.defineProperty(exports, "__esModule", ({
2468
+ value: true
2469
+ }));
2470
+ exports["default"] = resolveConfigPath;
2471
+ function path() {
2472
+ const data = _interopRequireWildcard(require("node:path"));
2473
+ path = function () {
2474
+ return data;
2475
+ };
2476
+ return data;
2477
+ }
2478
+ function _chalk() {
2479
+ const data = _interopRequireDefault(require("chalk"));
2480
+ _chalk = function () {
2481
+ return data;
2482
+ };
2483
+ return data;
2484
+ }
2485
+ function fs() {
2486
+ const data = _interopRequireWildcard(require("graceful-fs"));
2487
+ fs = function () {
2488
+ return data;
2489
+ };
2490
+ return data;
2491
+ }
2492
+ function _slash() {
2493
+ const data = _interopRequireDefault(require("slash"));
2494
+ _slash = function () {
2495
+ return data;
2496
+ };
2497
+ return data;
2498
+ }
2499
+ function _jestValidate() {
2500
+ const data = require("@pkg-nec/jest-validate");
2501
+ _jestValidate = function () {
2502
+ return data;
2503
+ };
2504
+ return data;
2505
+ }
2506
+ var _constants = __webpack_require__("./src/constants.ts");
2507
+ var _utils = __webpack_require__("./src/utils.ts");
2508
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
2509
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
2510
+ /**
2511
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2512
+ *
2513
+ * This source code is licensed under the MIT license found in the
2514
+ * LICENSE file in the root directory of this source tree.
2515
+ */
2516
+
2517
+ const isFile = filePath => fs().existsSync(filePath) && !fs().lstatSync(filePath).isDirectory();
2518
+ const getConfigFilename = ext => _constants.JEST_CONFIG_BASE_NAME + ext;
2519
+ function resolveConfigPath(pathToResolve, cwd, skipMultipleConfigError = false) {
2520
+ if (!path().isAbsolute(cwd)) {
2521
+ throw new Error(`"cwd" must be an absolute path. cwd: ${cwd}`);
2522
+ }
2523
+ const absolutePath = path().isAbsolute(pathToResolve) ? pathToResolve : path().resolve(cwd, pathToResolve);
2524
+ if (isFile(absolutePath)) {
2525
+ return absolutePath;
2526
+ }
2527
+
2528
+ // This is a guard against passing non existing path as a project/config,
2529
+ // that will otherwise result in a very confusing situation.
2530
+ // e.g.
2531
+ // With a directory structure like this:
2532
+ // my_project/
2533
+ // package.json
2534
+ //
2535
+ // Passing a `my_project/some_directory_that_doesnt_exist` as a project
2536
+ // name will resolve into a (possibly empty) `my_project/package.json` and
2537
+ // try to run all tests it finds under `my_project` directory.
2538
+ if (!fs().existsSync(absolutePath)) {
2539
+ throw new Error("Can't find a root directory while resolving a config file path.\n" + `Provided path to resolve: ${pathToResolve}\n` + `cwd: ${cwd}`);
2540
+ }
2541
+ return resolveConfigPathByTraversing(absolutePath, pathToResolve, cwd, skipMultipleConfigError);
2542
+ }
2543
+ const resolveConfigPathByTraversing = (pathToResolve, initialPath, cwd, skipMultipleConfigError) => {
2544
+ const configFiles = _constants.JEST_CONFIG_EXT_ORDER.map(ext => path().resolve(pathToResolve, getConfigFilename(ext))).filter(isFile);
2545
+ const packageJson = findPackageJson(pathToResolve);
2546
+ if (packageJson) {
2547
+ const jestKey = getPackageJsonJestKey(packageJson);
2548
+ if (jestKey) {
2549
+ if (typeof jestKey === 'string') {
2550
+ const absolutePath = path().isAbsolute(jestKey) ? jestKey : path().resolve(pathToResolve, jestKey);
2551
+ if (!isFile(absolutePath)) {
2552
+ throw new (_jestValidate().ValidationError)(`${_utils.BULLET}Validation Error`, ` Configuration in ${_chalk().default.bold(packageJson)} is not valid. ` + `Jest expects the string configuration to point to a file, but ${absolutePath} is not. ` + `Please check your Jest configuration in ${_chalk().default.bold(packageJson)}.`, _utils.DOCUMENTATION_NOTE);
2553
+ }
2554
+ configFiles.push(absolutePath);
2555
+ } else {
2556
+ configFiles.push(packageJson);
2557
+ }
2558
+ }
2559
+ }
2560
+ if (!skipMultipleConfigError && configFiles.length > 1) {
2561
+ throw new (_jestValidate().ValidationError)(...makeMultipleConfigsErrorMessage(configFiles));
2562
+ }
2563
+ if (configFiles.length > 0 || packageJson) {
2564
+ return configFiles[0] ?? packageJson;
2565
+ }
2566
+
2567
+ // This is the system root.
2568
+ // We tried everything, config is nowhere to be found ¯\_(ツ)_/¯
2569
+ if (pathToResolve === path().dirname(pathToResolve)) {
2570
+ throw new Error(makeResolutionErrorMessage(initialPath, cwd));
2571
+ }
2572
+
2573
+ // go up a level and try it again
2574
+ return resolveConfigPathByTraversing(path().dirname(pathToResolve), initialPath, cwd, skipMultipleConfigError);
2575
+ };
2576
+ const findPackageJson = pathToResolve => {
2577
+ const packagePath = path().resolve(pathToResolve, _constants.PACKAGE_JSON);
2578
+ if (isFile(packagePath)) {
2579
+ return packagePath;
2580
+ }
2581
+ return undefined;
2582
+ };
2583
+ const getPackageJsonJestKey = packagePath => {
2584
+ try {
2585
+ const content = fs().readFileSync(packagePath, 'utf8');
2586
+ const parsedContent = JSON.parse(content);
2587
+ if ('jest' in parsedContent) {
2588
+ return parsedContent.jest;
2589
+ }
2590
+ } catch {}
2591
+ return undefined;
2592
+ };
2593
+ const makeResolutionErrorMessage = (initialPath, cwd) => 'Could not find a config file based on provided values:\n' + `path: "${initialPath}"\n` + `cwd: "${cwd}"\n` + 'Config paths must be specified by either a direct path to a config\n' + 'file, or a path to a directory. If directory is given, Jest will try to\n' + `traverse directory tree up, until it finds one of those files in exact order: ${_constants.JEST_CONFIG_EXT_ORDER.map(ext => `"${getConfigFilename(ext)}"`).join(' or ')}.`;
2594
+ function extraIfPackageJson(configPath) {
2595
+ if (configPath.endsWith(_constants.PACKAGE_JSON)) {
2596
+ return '`jest` key in ';
2597
+ }
2598
+ return '';
2599
+ }
2600
+ const makeMultipleConfigsErrorMessage = configPaths => [`${_utils.BULLET}${_chalk().default.bold('Multiple configurations found')}`, [...configPaths.map(configPath => ` * ${extraIfPackageJson(configPath)}${(0, _slash().default)(configPath)}`), '', ' Implicit config resolution does not allow multiple configuration files.', ' Either remove unused config files or select one explicitly with `--config`.'].join('\n'), _utils.DOCUMENTATION_NOTE];
2601
+
2602
+ /***/ },
2603
+
2604
+ /***/ "./src/setFromArgv.ts"
2605
+ (__unused_webpack_module, exports, __webpack_require__) {
2606
+
2607
+
2608
+
2609
+ Object.defineProperty(exports, "__esModule", ({
2610
+ value: true
2611
+ }));
2612
+ exports["default"] = setFromArgv;
2613
+ var _utils = __webpack_require__("./src/utils.ts");
2614
+ /**
2615
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2616
+ *
2617
+ * This source code is licensed under the MIT license found in the
2618
+ * LICENSE file in the root directory of this source tree.
2619
+ */
2620
+
2621
+ const specialArgs = new Set(['_', '$0', 'h', 'help', 'config']);
2622
+ function setFromArgv(options, argv) {
2623
+ const argvToOptions = Object.keys(argv).reduce((options, key) => {
2624
+ if (argv[key] === undefined || specialArgs.has(key)) {
2625
+ return options;
2626
+ }
2627
+ switch (key) {
2628
+ case 'coverage':
2629
+ options.collectCoverage = argv[key];
2630
+ break;
2631
+ case 'json':
2632
+ options.useStderr = argv[key];
2633
+ break;
2634
+ case 'watchAll':
2635
+ options.watch = false;
2636
+ options.watchAll = argv[key];
2637
+ break;
2638
+ case 'env':
2639
+ options.testEnvironment = argv[key];
2640
+ break;
2641
+ case 'config':
2642
+ break;
2643
+ case 'coverageThreshold':
2644
+ case 'globals':
2645
+ case 'haste':
2646
+ case 'moduleNameMapper':
2647
+ case 'testEnvironmentOptions':
2648
+ case 'transform':
2649
+ const str = argv[key];
2650
+ if ((0, _utils.isJSONString)(str)) {
2651
+ options[key] = JSON.parse(str);
2652
+ }
2653
+ break;
2654
+ default:
2655
+ options[key] = argv[key];
2656
+ }
2657
+ return options;
2658
+ }, {});
2659
+ return {
2660
+ ...options,
2661
+ ...((0, _utils.isJSONString)(argv.config) ? JSON.parse(argv.config) : null),
2662
+ ...argvToOptions
2663
+ };
2664
+ }
2665
+
2666
+ /***/ },
2667
+
2668
+ /***/ "./src/stringToBytes.ts"
2669
+ (__unused_webpack_module, exports) {
2670
+
2671
+
2672
+
2673
+ Object.defineProperty(exports, "__esModule", ({
2674
+ value: true
2675
+ }));
2676
+ exports["default"] = void 0;
2677
+ /**
2678
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2679
+ *
2680
+ * This source code is licensed under the MIT license found in the
2681
+ * LICENSE file in the root directory of this source tree.
2682
+ */
2683
+
2684
+ /**
2685
+ * Converts a string representing an amount of memory to bytes.
2686
+ *
2687
+ * @param input The value to convert to bytes.
2688
+ * @param percentageReference The reference value to use when a '%' value is supplied.
2689
+ */
2690
+ function stringToBytes(input, percentageReference) {
2691
+ if (input === null || input === undefined) {
2692
+ return input;
2693
+ }
2694
+ if (typeof input === 'string') {
2695
+ if (Number.isNaN(Number.parseFloat(input.slice(-1)))) {
2696
+ // eslint-disable-next-line prefer-const
2697
+ let [, numericString, trailingChars] = input.match(/(.*?)([^\d.-]+)$/i) || [];
2698
+ if (trailingChars && numericString) {
2699
+ const numericValue = Number.parseFloat(numericString);
2700
+ trailingChars = trailingChars.toLowerCase();
2701
+ switch (trailingChars) {
2702
+ case '%':
2703
+ input = numericValue / 100;
2704
+ break;
2705
+ case 'kb':
2706
+ case 'k':
2707
+ return numericValue * 1000;
2708
+ case 'kib':
2709
+ return numericValue * 1024;
2710
+ case 'mb':
2711
+ case 'm':
2712
+ return numericValue * 1000 * 1000;
2713
+ case 'mib':
2714
+ return numericValue * 1024 * 1024;
2715
+ case 'gb':
2716
+ case 'g':
2717
+ return numericValue * 1000 * 1000 * 1000;
2718
+ case 'gib':
2719
+ return numericValue * 1024 * 1024 * 1024;
2720
+ }
2721
+ }
2722
+
2723
+ // It ends in some kind of char so we need to do some parsing
2724
+ } else {
2725
+ input = Number.parseFloat(input);
2726
+ }
2727
+ }
2728
+ if (typeof input === 'number') {
2729
+ if (input === 0) {
2730
+ return 0;
2731
+ } else if (input <= 1 && input > 0) {
2732
+ if (percentageReference) {
2733
+ return Math.floor(input * percentageReference);
2734
+ } else {
2735
+ throw new Error('For a percentage based memory limit a percentageReference must be supplied');
2736
+ }
2737
+ } else if (input > 1) {
2738
+ return Math.floor(input);
2739
+ } else {
2740
+ throw new Error('Unexpected numerical input');
2741
+ }
2742
+ }
2743
+ throw new Error('Unexpected input');
2744
+ }
2745
+
2746
+ // https://github.com/import-js/eslint-plugin-import/issues/1590
2747
+ var _default = exports["default"] = stringToBytes;
2748
+
2749
+ /***/ },
2750
+
2751
+ /***/ "./src/utils.ts"
2752
+ (__unused_webpack_module, exports) {
2753
+
2754
+
2755
+
2756
+ Object.defineProperty(exports, "__esModule", ({
2757
+ value: true
2758
+ }));
2759
+ exports.resolve = exports.replaceRootDirInPath = exports.isJSONString = exports.escapeGlobCharacters = exports._replaceRootDirTags = exports.DOCUMENTATION_NOTE = exports.BULLET = void 0;
2760
+ function path() {
2761
+ const data = _interopRequireWildcard(require("node:path"));
2762
+ path = function () {
2763
+ return data;
2764
+ };
2765
+ return data;
2766
+ }
2767
+ function _chalk() {
2768
+ const data = _interopRequireDefault(require("chalk"));
2769
+ _chalk = function () {
2770
+ return data;
2771
+ };
2772
+ return data;
2773
+ }
2774
+ function _jestResolve() {
2775
+ const data = _interopRequireDefault(require("@pkg-nec/jest-resolve"));
2776
+ _jestResolve = function () {
2777
+ return data;
2778
+ };
2779
+ return data;
2780
+ }
2781
+ function _jestValidate() {
2782
+ const data = require("@pkg-nec/jest-validate");
2783
+ _jestValidate = function () {
2784
+ return data;
2785
+ };
2786
+ return data;
2787
+ }
2788
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
2789
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
2790
+ /**
2791
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2792
+ *
2793
+ * This source code is licensed under the MIT license found in the
2794
+ * LICENSE file in the root directory of this source tree.
2795
+ */
2796
+
2797
+ const BULLET = exports.BULLET = _chalk().default.bold('\u25CF ');
2798
+ const DOCUMENTATION_NOTE = exports.DOCUMENTATION_NOTE = ` ${_chalk().default.bold('Configuration Documentation:')}
2799
+ https://jestjs.io/docs/configuration
2800
+ `;
2801
+ const createValidationError = message => new (_jestValidate().ValidationError)(`${BULLET}Validation Error`, message, DOCUMENTATION_NOTE);
2802
+ const resolve = (resolver, {
2803
+ key,
2804
+ filePath,
2805
+ rootDir,
2806
+ optional
2807
+ }) => {
2808
+ const module = _jestResolve().default.findNodeModule(replaceRootDirInPath(rootDir, filePath), {
2809
+ basedir: rootDir,
2810
+ resolver: resolver || undefined
2811
+ });
2812
+ if (!module && !optional) {
2813
+ throw createValidationError(` Module ${_chalk().default.bold(filePath)} in the ${_chalk().default.bold(key)} option was not found.
2814
+ ${_chalk().default.bold('<rootDir>')} is: ${rootDir}`);
2815
+ }
2816
+ /// can cast as string since nulls will be thrown
2817
+ return module;
2818
+ };
2819
+ exports.resolve = resolve;
2820
+ const escapeGlobCharacters = path => path.replaceAll(/([!()*?[\\\]{}])/g, '\\$1');
2821
+ exports.escapeGlobCharacters = escapeGlobCharacters;
2822
+ const replaceRootDirInPath = (rootDir, filePath) => {
2823
+ if (!filePath.startsWith('<rootDir>')) {
2824
+ return filePath;
2825
+ }
2826
+ return path().resolve(rootDir, path().normalize(`./${filePath.slice('<rootDir>'.length)}`));
2827
+ };
2828
+ exports.replaceRootDirInPath = replaceRootDirInPath;
2829
+ const _replaceRootDirInObject = (rootDir, config) => {
2830
+ const newConfig = {};
2831
+ for (const configKey in config) {
2832
+ newConfig[configKey] = configKey === 'rootDir' ? config[configKey] : _replaceRootDirTags(rootDir, config[configKey]);
2833
+ }
2834
+ return newConfig;
2835
+ };
2836
+ const _replaceRootDirTags = (rootDir, config) => {
2837
+ if (config == null) {
2838
+ return config;
2839
+ }
2840
+ switch (typeof config) {
2841
+ case 'object':
2842
+ if (Array.isArray(config)) {
2843
+ /// can be string[] or {}[]
2844
+ return config.map(item => _replaceRootDirTags(rootDir, item));
2845
+ }
2846
+ if (config instanceof RegExp) {
2847
+ return config;
2848
+ }
2849
+ return _replaceRootDirInObject(rootDir, config);
2850
+ case 'string':
2851
+ return replaceRootDirInPath(rootDir, config);
2852
+ }
2853
+ return config;
2854
+ };
2855
+ exports._replaceRootDirTags = _replaceRootDirTags;
2856
+ // newtype
2857
+ const isJSONString = text => text != null && typeof text === 'string' && text.startsWith('{') && text.endsWith('}');
2858
+ exports.isJSONString = isJSONString;
2859
+
2860
+ /***/ }
2861
+
2862
+ /******/ });
2863
+ /************************************************************************/
2864
+ /******/ // The module cache
2865
+ /******/ var __webpack_module_cache__ = {};
2866
+ /******/
2867
+ /******/ // The require function
2868
+ /******/ function __webpack_require__(moduleId) {
2869
+ /******/ // Check if module is in cache
2870
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
2871
+ /******/ if (cachedModule !== undefined) {
2872
+ /******/ return cachedModule.exports;
2873
+ /******/ }
2874
+ /******/ // Create a new module (and put it into the cache)
2875
+ /******/ var module = __webpack_module_cache__[moduleId] = {
2876
+ /******/ id: moduleId,
2877
+ /******/ loaded: false,
2878
+ /******/ exports: {}
2879
+ /******/ };
2880
+ /******/
2881
+ /******/ // Execute the module function
2882
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
2883
+ /******/
2884
+ /******/ // Flag the module as loaded
2885
+ /******/ module.loaded = true;
2886
+ /******/
2887
+ /******/ // Return the exports of the module
2888
+ /******/ return module.exports;
2889
+ /******/ }
2890
+ /******/
2891
+ /******/ // expose the module cache
2892
+ /******/ __webpack_require__.c = __webpack_module_cache__;
2893
+ /******/
2894
+ /************************************************************************/
2895
+ /******/
2896
+ /******/ // module cache are used so entry inlining is disabled
2897
+ /******/ // startup
2898
+ /******/ // Load entry module and return exports
2899
+ /******/ var __webpack_exports__ = __webpack_require__("./src/index.ts");
2900
+ /******/ module.exports = __webpack_exports__;
2901
+ /******/
2902
+ /******/ })()
2903
+ ;