I am using Angular 7 and Jest. When I was running jest with --codecoverage
, all my tests passed but many branches in the constructor were not covered
(similar to: Branches on constructor not covered).
I spent quite a lot of time checking everywhere how to solve it and it seemed I had to upgrade jest-preset-angular
to version 7. After I did it, all my test suites fail to run with the following message:
src/app/whatever.component.spec.ts
● Test suite failed to run
TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
error TS2688: Cannot find type definition file for 'jasmine'.
I've been looking around and I tried to apply the solutions I found (such as Cannot find type definition file for 'jasmine', ERROR in error TS2688: Cannot find type definition file for 'jest', ...) but none worked.
I copy here some of the dependencies I have in package.json:
"jest": "^24.1.0",
"jest-junit": "^6.3.0",
"jest-preset-angular": "^7.0.1",
"ts-node": "~7.0.1",
"tslint": "~5.9.1",
"typescript": "3.2.4"
My previous version was:
"jest-preset-angular": "^6.0.2",
Update: I started my project with Angular 6 and Jasmine and I updated it to Angular 7 and Jest. I don't know if this is an important information.