10

Writing Unit Tests in Angular with Jest

“It works on my machine” is a phrase that won’t lose its beauty with time. It is a shield for many engineers and a nightmare for the quality assurance professionals. But honestly, what’s a better way for your application’s robustness than writing tests? And when it comes to writing unit tests, my personal favorite is Jest. That is because it is super-fast, lightweight, and has an easy API to write tests. More importantly, it is faster than the Karma and Jasmine setup that comes out of the box with Angular. In this chapter, you’ll learn how to configure Jest with Angular to run these tests in parallel. You’ll learn how to test components, services, and pipes with Jest. You’ll also learn how to mock dependencies ...

Get Angular Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.