If you are using Angular 8, update the verison for @angular-builders/jest as well.
Answer from Akshay Rana on Stack Overflow
» npm install @angular-builders/jest
npm - Could not find the implementation for builder @angular-builders/jest:run - Stack Overflow
jestjs - Angular configuration when using Jest - Stack Overflow
intellij idea - Run individual Jest unit test for Angular 16+ with ng test - Stack Overflow
Is Jest still going to be integrated officially with Angular?
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
» npm install @angular-builders/jest
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?