'Jest runs tests in node_modules after update to Angular 13
After updating Angular to Version 13 the jest-runner runs tests in the node_module. For instance:
Test suite failed to run
Cannot find module 'chai' from 'node_modules_/@compodoc/compodoc/src/app/compiler/deps/helpers/symbol-helper.spec.ts'
1 | import { SymbolHelper } from './symbol-helper';
2 | import { ts, SyntaxKind } from 'ts-simple-ast';
> 3 | import { expect } from 'chai';
| ^
My jest configuration looks like following snippet:
"jest": {
"globals": {
"ts-jest": {
"tsconfig": "<rootDir>/tsconfig.json",
"stringifyContentPathRegex": "\\.(html|svg)$",
"isolatedModules": true
}
},
"preset": "jest-preset-angular",
"setupFilesAfterEnv": [
"<rootDir>/setup.jest.ts"
],
"testRunner": "jasmine2",
"transformIgnorePatterns": [
"node_modules/(?!.*\\.mjs$)"
],
"transform": {
"^.+\\.(ts|js|mjs|html|svg)$": "jest-preset-angular"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$",
"resolver": "jest-preset-angular/build/resolvers/ng-jest-resolver.js",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
]}
How can I exclude the node_folder. The former way seems not working:
"transformIgnorePatterns": [
"node_modules"
],
How can I configure jest properly?
Solution 1:[1]
Was fixed:
"ts-jest": "^27.1.3",
was missing before it was a minor version.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andi |
