Chapter 9. Angular 2 Testing

This chapter will cover the following recipes:

  • Creating a minimum viable unit test suite with Karma, Jasmine, and TypeScript
  • Writing a minimum viable unit test suite for a simple component
  • Writing a minimum viable end-to-end test suite for a simple application
  • Unit testing a synchronous service
  • Unit testing a component with a service dependency using stubs
  • Unit testing a component with a service dependency using spies

Introduction

Writing tests is like brushing your teeth. You can get away with skipping it for a while, but it'll catch up with you eventually.

The world of testing is awash with conflicting ideologies, platitudes, and grandstanding. What's more, there is a dizzying array of tools available that allow you to write ...

Get Angular 2 Cookbook 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.