Skip to content

Commit a97a5af

Browse files
authored
(fix): jest config parsing shouldn't silently fail on error (#499)
- before if your jest.config.js had an error in it, the try/catch would just ignore it and pretend like your jest.config.js didn't exist - this caused me a lot of confusion as to why my customizations seemingly weren't being read at all - instead of try/catching a MODULE_NOT_FOUND, check if it exists first, and only then do parsing - and let it throw an error if there is one, don't cover it up
1 parent df22fe3 commit a97a5af

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,13 @@ prog
534534
),
535535
...appPackageJson.jest,
536536
};
537-
try {
538-
// Allow overriding with jest.config
537+
538+
// Allow overriding with jest.config
539+
const jestConfigExists = await fs.pathExists(paths.jestConfig);
540+
if (jestConfigExists) {
539541
const jestConfigContents = require(paths.jestConfig);
540542
jestConfig = { ...jestConfig, ...jestConfigContents };
541-
} catch {}
543+
}
542544

543545
argv.push(
544546
'--config',

0 commit comments

Comments
 (0)