Search⌘ K
AI Features

Introduction to Testing in RxJS

Explore the fundamentals of testing in RxJS by understanding how to verify Observable outputs. Learn about subscriber-based testing and the limitations of this approach. Discover Marble Tests as a method to simulate virtual time, enabling precise synchronous testing of asynchronous data streams.

We'll cover the following...
widget

As in every software development paradigm, testing is the most important aspect to maintain a bug-free, scalable codebase. Even reactive applications need their tests to ensure that the data stream is running in the right direction. But, how is testing performed in this case?

According to what we have learned so far, a subscriber will subscribe to an Observable and will receive some values. In that case, we can perform tests on the values that are expected to be received by the subscriber. However, that approach, as we will see in the next lesson, has a few downsides, mostly related to testing Observables that emit multiple values over different time intervals.

Those downsides will be overcome by using Marble Tests. They allow us to provide a virtual time to the Observables that we are testing, in order to test asynchronous data streams in a synchronous way.

With that being said, let’s jump right in.