Skip to content

Commit

Permalink
Fixes issues with trying to read an ESM Jest config. (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotny authored Jul 26, 2022
1 parent c337538 commit 75215d4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/utils/files/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@ const {readJsonSync} = require('fs-extra');

const locate = require('./locate');

const packageJson = readJsonSync(locate('package.json'), {throws: false}) || {};
const jestConfigLocation = locate(['jest.config.cjs', 'jest.config.js', 'jest.config.ts']);
const jestConfig = jestConfigLocation ? require(jestConfigLocation) : {};

const getJestConfig = () => {
if (jestConfigLocation) {
try {
require(jestConfigLocation);
} catch {
return {};
}
}

return {};
};

const packageJson = readJsonSync(locate('package.json'), {throws: false}) || {};
const jestConfig = getJestConfig();
const tsConfig = readJsonSync(locate('tsconfig.json'), {throws: false}) || {};

module.exports = {
Expand Down

0 comments on commit 75215d4

Please sign in to comment.