Created by: mkarajohn
Resolves #8965 (closed)
Problem & Cause
As described in the linked issue, when a CRA project is ejected, the modulePaths
entry of the jest config includes an array of absolute paths, if a baseUrl
is defined in the tsconfig.json
or jsconfig.json
.
The array is created here exported as additionalModulePaths
.
Since this exported array of additionalModulePaths
is also used in the webpack.config.js
here, where absolute paths are in fact needed, we cannot be directly modifying the way the additionalModulePaths
array contents are created.
Solution
What this PR does in order to fix the issue, is to translate the absolute paths to relative ones in the createJestConfig.js
file here, since adding absolute paths in the modulePaths
is problematic, in cases such as CI pipelines, or simply someone else trying to run the tests on their own machine. Making them relative to the rootDir
solves any issues.