» npm install @angular-builders/jest
Is Jest still going to be integrated officially with Angular?
jestjs - Angular configuration when using Jest - Stack Overflow
@angular-builders/jest - Support jest.config in typescript
How to provide `setupFilesAfterEnv` to jest when using jest builder.
How do I install Jest in an Angular project?
Is Angular Testing Library compatible with Angular 17 and standalone components?
What is Angular Testing Library and how does it differ from TestBed?
I've been having a nightmare trying to reconfigure an old project's tests from Jasmine/Karma to Jest, because I have many coworkers advocating for it. But I'm surprised to see that while Karma has been deprecated for almost 2 years now, ng new and the refreshed Angular docs still only go over Karma, and make no mention of Jest or other testing frameworks at all https://angular.dev/guide/testing#other-test-frameworks.
This announcement https://blog.angular.dev/moving-angular-cli-to-jest-and-web-test-runner-ef85ef69ceca mentions @angular-devkit/build-angular:jest but I'm not sure if that's worth using - googling it actually points me to https://www.npmjs.com/package/@angular-builders/jest first but I'm not sure if this is something official.
jest-preset-angular also appears in lots of guides but it seems like every guide has a different way to set that up and I find its documentation kind of a nightmare of its own. Doesn't feel particularly futureproof.
Is Jest going to be a passing fad for Angular? Is there any news of deeper, documented integration anytime soon? Is Web Test Runner support at least close to being ready?
In angular.json file specify jest runner for test architect:
"test": {
"builder": "@angular-builders/jest:run",
"options": {}
},
I assume that you have installed it, when switched to jest
- Created a setupJest.ts file in the root and import jest-preset-angular
- add the Jest configuration in the package.json
"jest": {
"preset": "jest-preset-angular",
"setupFilesAfterEnv": [
"<rootDir>/setupJest.ts"
]
}
modify the test script to use Jest instead of ng test.
run npm test