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
{{ message }}
Repository navigation
Jest tests fail when TypeScrip tsconfig baseUrl set to '.' and the project is nested in a src directory. moduleNameMapper error. #7833
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.
Activity