Skip to content

Commit 45e6217

Browse files
authoredOct 1, 2018
Fix absolute paths on eject (#5214)
1 parent bf5a4bf commit 45e6217

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎packages/react-scripts/scripts/utils/createJestConfig.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,20 @@ module.exports = (resolve, rootDir, isEjecting) => {
2222
// in Jest configs. We need help from somebody with Windows to determine this.
2323
const config = {
2424
collectCoverageFrom: ['src/**/*.{js,jsx}'],
25-
resolver: require.resolve('jest-pnp-resolver'),
26-
setupFiles: [require.resolve('react-app-polyfill/jsdom')],
25+
26+
// TODO: this breaks Yarn PnP on eject.
27+
// But we can't simply emit this because it'll be an absolute path.
28+
// The proper fix is to write jest.config.js on eject instead of a package.json key.
29+
// Then these can always stay as require.resolve()s.
30+
resolver: isEjecting
31+
? 'jest-pnp-resolver'
32+
: require.resolve('jest-pnp-resolver'),
33+
setupFiles: [
34+
isEjecting
35+
? 'react-app-polyfill/jsdom'
36+
: require.resolve('react-app-polyfill/jsdom'),
37+
],
38+
2739
setupTestFrameworkScriptFile: setupTestsFile,
2840
testMatch: [
2941
'<rootDir>/src/**/__tests__/**/*.{js,jsx}',

0 commit comments

Comments
 (0)
Please sign in to comment.