You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a project is nested somewhere in a directory named src, and the baseUrl in tsconfig.json is set to ".", all tests will fail with the following error:
FAIL src/App.test.tsx
● Test suite failed to run
Configuration error:
Could not locate module /Users/pbeshai/Workspace/bug-report/src/nested-src-bug-ts/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault mapped as:
/Users/pbeshai/Workspace/bug-report/src/nested-src-bug-ts/src/nested-src-bug-ts/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/src\/(.*)$/": "/Users/pbeshai/Workspace/bug-report/src/nested-src-bug-ts/src/$1"
},
"resolver": null
}
After some investigation, I believe this is because the moduleNameMapper is not prefixed with ^ and so it matches the src earlier in the path.
Describe the bug
When a project is nested somewhere in a directory named
src
, and the baseUrl in tsconfig.json is set to"."
, all tests will fail with the following error:After some investigation, I believe this is because the
moduleNameMapper
is not prefixed with^
and so it matches thesrc
earlier in the path.Steps to reproduce
(Write your steps here:)
baseUrl: "."
to tsconfig.jsonReproducible demo
https://github.com/pbeshai/cra-nested-src-bug-ts
Proposed Solution
In #7755 baseUrl was allowed to be set to
.
. If we modify ... I now see this is already fixed in #7818 and #7822.I'll post and close this just in case someone else is stumbling on this problem and couldn't find any results.
The text was updated successfully, but these errors were encountered: