Skip to content

Commit 0e42339

Browse files
Merge pull request #2 from SAINIAbhishek/jest_update_28.1.2
jest update.
2 parents 30a5d06 + 9eac4f3 commit 0e42339

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This project was generated with [Angular CLI](https://github.com/angular/angular
2222
- Migrate tslint to esLint
2323
- Migrate to Angular 12
2424
- Migrate to Angular 13
25+
- Jest to 28.1.2
2526

2627
## Unit Tests
2728

jest.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
require('jest-preset-angular/ngcc-jest-processor');
1+
const {pathsToModuleNameMapper} = require('ts-jest');
2+
const {paths} = require('./tsconfig.json').compilerOptions;
3+
4+
globalThis.ngJest = {
5+
skipNgcc: false,
6+
tsconfig: '<rootDir>/tsconfig.spec.json',
7+
};
28

39
module.exports = {
410
preset: 'jest-preset-angular',
11+
globalSetup: 'jest-preset-angular/global-setup',
512
setupFilesAfterEnv: [
613
'<rootDir>/src/setupJest.ts'
714
], // setup env file
@@ -17,6 +24,7 @@ module.exports = {
1724
},
1825
}, // need to be available in all test environments.
1926
moduleNameMapper: {
27+
...pathsToModuleNameMapper(paths, {prefix: '<rootDir>'}),
2028
'^@App/(.*)$': '<rootDir>/src/app/$1',
2129
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
2230
},
@@ -30,7 +38,10 @@ module.exports = {
3038
// Do not change with jest-circus (jest 27.1.1)
3139
// a lot of tests won't success (Error: Test functions cannot both take a 'done' callback...)
3240
testRunner : "jest-jasmine2",
41+
testEnvironmentOptions: {
42+
url: 'http://localhost/',
43+
},
3344
transformIgnorePatterns: [
34-
'node_modules/',
45+
'node_modules/(?!.*\\.mjs$|preact|@agm)',
3546
],
3647
};

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,29 @@
7575
"@types/compression": "^1.7.2",
7676
"@types/express": "^4.17.13",
7777
"@types/jasminewd2": "~2.0.3",
78-
"@types/jest": "^27.0.1",
78+
"@types/jest": "^28.1.2",
7979
"@types/mime-types": "^2.1.1",
8080
"@types/node": "^12.11.1",
8181
"@typescript-eslint/eslint-plugin": "4.16.1",
8282
"@typescript-eslint/parser": "4.16.1",
83-
"babel-jest": "^27.1.1",
83+
"babel-jest": "^28.1.2",
8484
"compression": "^1.7.4",
8585
"eslint": "^7.6.0",
8686
"eslint-plugin-import": "^2.26.0",
8787
"eslint-plugin-jsdoc": "^39.3.2",
8888
"eslint-plugin-prefer-arrow": "^1.2.3",
8989
"husky": "^8.0.1",
9090
"http-server": "^0.12.3",
91-
"jest": "^27.1.1",
92-
"jest-html-reporter": "^3.1.0",
93-
"jest-jasmine2": "^27.5.1",
94-
"jest-preset-angular": "^9.0.7",
91+
"jest": "^28.1.2",
92+
"jest-jasmine2": "^28.1.0",
93+
"jest-html-reporter": "^3.5.0",
94+
"jest-preset-angular": "^12.0.1",
9595
"mime-types": "^2.1.34",
9696
"lint-staged": "^13.0.2",
9797
"protractor": "~7.0.0",
9898
"sass": "^1.52.3",
9999
"ts-loader": "^8.2.0",
100+
"ts-jest": "^28.0.2",
100101
"ts-node": "~8.3.0",
101102
"typescript": "4.6.4",
102103
"webpack": "^4.46.0",

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"strict": true,
2727
"noImplicitAny": true,
2828
"noUnusedLocals": true,
29-
"skipLibCheck": true
29+
"skipLibCheck": true,
30+
"paths": {
31+
}
3032
},
3133
"angularCompilerOptions": {
3234
"fullTemplateTypeCheck": true,

0 commit comments

Comments
 (0)