I created a modularization of the paths in ts.config, however, when I added moduleNameMapper to jest.config.js it returned the error:
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: jest.config.js.
The file must be included in at least one of the projects provided.
.tsconfig.js
{
"compilerOptions": {
...
"paths": {
"@/*": ["*"]
}
...
}
}
jest.config.js
module.exports = {
roots: ['<rootDir>/src'],
collectCoverageFrom: [
'<rootDir>/src/**/*.{ts, tsx}'
],
coverageDirectory: 'coverage',
testEnvironment: 'node',
transform: {
'.+\\.tsx$': 'ts-jest',
'.+\\.ts?$': 'ts-jest'
},
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1'
}
}