Angular with Jest Testing
1 min readFeb 9, 2022
Jest is a painless JavaScript testing platform.
- Jest is a testing platform, widely adapted by many large companies and swiftly adopted by the React community.
- Sits on top of Jasmine, so the API is nearly identical.
- Focuses on Developer Experience (speed and ease of use is the first priority.)
- Provides meaningful error messages.
- Runs on Continuous Integration servers without extra tooling (abstracting the DOM with jsdom library.)
- Provides code coverage out of the box.
- Integrates with Babel and TypeScript seamlessly.
And what’s most important is that it provides a smart, immersive watch mode. The watch mode runs only tests affected by git file changes — it also runs failed tests first and is able to bail on first error so the feedback loop is ~10x faster than with Karma, depending on test suite size.
Add to application
yarn add --dev jest jest-preset-angular @types/jest
where:
- jest — Jest testing platform
- jest-preset-angular — configuration preset with common settings setup for you
- @types/jest — Jest typings