Marble-Testing Pattern

Learn the concepts of the marble-testing pattern.

The marble diagram in code

Marble diagrams are very useful for visualizing observable execution. We learned about marble diagrams in The Power of the Reactive Paradigm, and we’ve used them in almost all the reactive patterns we’ve implemented in this course. At this point, I think we’re very familiar with marble diagrams. They’re simple to understand and delightful to read. So why not also use them in code? What you’ll be surprised to know is that RxJS introduced marble testing as an intuitive and clean way to test observables.

Let’s discover what marble testing is about. We’ll start by explaining the syntax in the next section and then learn how we can write marble tests in our code.

Understanding the syntax

To understand the syntax, we should know the following semantics:

Get hands-on with 1200+ tech skills courses.