DEV Community

kreuzerk
kreuzerk

Posted on • Originally published at Medium on

How to marble test RxJS Subjects

How to bridge the gap between the timing of function calls and Observables

Asynchronous code is hard! It’s hard to write and to test.

RxJs has changed the way we think about asynchrony. Instead of using Promises, we nowadays deal with streams in the form of Observables or Subjects. RxJs provides us with many out of the box operators to create, merge, or transform streams.

But we do not only get great tools for runtime code, but we also get amazing tools to test streams.

Marble diagrams are a great way of modeling streams. They are used throughout many tutorials and can now also be used in tests to assert streams.

In case you never heard of marble testing I recommend you to checkout the following article.

Marble testing with RxJS testing utils

Marble testing is great! Many people use it to test their Observables. But what about Subjects?

Find out more...

Top comments (0)