Skip to content

Commit

Permalink
(fix): jest config parsing shouldn't silently fail on error
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 committed Feb 7, 2020
1 parent b3632fe commit 349b98d
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 349b98d

Please sign in to comment.