Chapter 5. Jasmine Spies

In this chapter, we will cover:

  • Writing Jasmine tests using the spyOn() method and special matchers for spies
  • Writing Jasmine tests using tracking properties
  • Writing Jasmine tests with your own custom spy method
  • Using jasmine.any and jasmine.objectContaining
  • Writing Jasmine tests to mock the JavaScript timeout functions

Introduction

The primary objective of unit testing is to test a method, object, or component in isolation and see how it behaves in different circumstances. However, there are situations where a method/object has dependencies on other methods or objects. In this scenario, we need to design tests/specs across the units/methods or components to validate behavior or simulate a real-time scenario. However, due to ...

Get Jasmine 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.