Skip to content

Commit

Permalink
(fix): jest config parsing shouldn't silently fail on error (#499)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
agilgur5 authored Feb 7, 2020
1 parent df22fe3 commit a97a5af
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,13 @@ prog
),
...appPackageJson.jest,
};
try {
// Allow overriding with jest.config

// Allow overriding with jest.config
const jestConfigExists = await fs.pathExists(paths.jestConfig);
if (jestConfigExists) {
const jestConfigContents = require(paths.jestConfig);
jestConfig = { ...jestConfig, ...jestConfigContents };
} catch {}
}

argv.push(
'--config',
Expand Down

0 comments on commit a97a5af

Please sign in to comment.