I upgraded my project to Angular 13 and jest needed some changes too.
Now any reference to 'src' can not be resolved.
For example:
Cannot find module 'src/app/app.component/app.component.test' from 'src/dashboard/reports/modules/tables/matrix-table/matrix-table.test.ts'
This is my jest.config.js
const { compilerOptions } = require('./tsconfig.test.json');
const { pathsToModuleNameMapper } = require('ts-jest/utils');
module.exports = {
preset: "jest-preset-angular",
testMatch: ["**/*.test.ts"],
coverageReporters: ["json", "lcov", "text", "clover", "cobertura"],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
globals: {
"ts-jest": {
tsconfig: "tsconfig.test.json"
}
}
};
What should I change in my jest config in order for it to resolve the root to src?