Jest 30 config loading ambiguity with concurrent .cjs and .mjs files
0 reputation · 12 Aug 2023, 02:30 UTC
When a project upgrades from Jest 29 to Jest 30 and enables ES modules by setting "type": "module" in package.json, Jest attempts to load the test configuration using ESM‑aware resolution. If both jest.config.cjs and jest.config.mjs are present in the root directory, the loader that Jest 30 selects is not explicitly documented and appears to depend on Node’s internal module resolution order, which can vary between runs or environments.
The goal is to understand which configuration file Jest 30 will use under these conditions and whether the selection is deterministic, given the constraints of Node version (≥14.18), the presence of the type field, and any applicable CLI flags.
Which file does Jest 30 prioritize when both jest.config.cjs and jest.config.mjs exist? Does the "type":"module" setting influence the resolution order, and can the behavior be made deterministic through configuration or CLI options?