LiveLoveApp logo

Testing

Goals

  • Learn the marble syntax for testing Observables
  • Learn to use the TestScheduler
  • Learn to write a basic test using the TestScheduler and the marble syntax
  • Learn to test subscribing
  • Learn to test for completion and error notifications

Why

Testing RxJs Observables is a necessary skill in order to test custom operators. Using the testing library, along with the TestScheduler class, is not necessary to test web applications that use RxJS and Observables.

It is very likely the case that using a general-purpose, or framework-specific, unit testing library provides the ability to create automated testing for your application when using RxJS and Observables. As such, it is recommended to not use the RxJS testing library for automated tests for an application that uses RxJS unless you are using custom operators.

It is important to create tests for custom operators, especially those that provide critical functionality and behaviors to your application.

In this section we'll learn how to write unit tests using the RxJS testing library.