Skip to content

Commit

Permalink
fix(testing): add support for jest.config.js (#229)
Browse files Browse the repository at this point in the history
* fix(testing): add support for jest.config.js

* Move jest config to paths

* specify .js extension
  • Loading branch information
Aidurber authored and jaredpalmer committed Oct 14, 2019
1 parent b86f715 commit 22c2416
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const paths = {
appErrors: resolveApp('errors'),
appDist: resolveApp('dist'),
appConfig: resolveApp('tsdx.config.js'),
jestConfig: resolveApp('jest.config.js'),
};
18 changes: 13 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,23 @@ prog
});

const argv = process.argv.slice(2);
let jestConfig = {
...createJestConfig(
relativePath => path.resolve(__dirname, '..', relativePath),
paths.appRoot
),
...appPackageJson.jest,
};
try {
// Allow overriding with jest.config
const jestConfigContents = require(paths.jestConfig);
jestConfig = { ...jestConfig, ...jestConfigContents };
} catch {}

argv.push(
'--config',
JSON.stringify({
...createJestConfig(
relativePath => path.resolve(__dirname, '..', relativePath),
paths.appRoot
),
...appPackageJson.jest,
...jestConfig,
})
);

Expand Down

0 comments on commit 22c2416

Please sign in to comment.