Getting Started with Marble Testing

Todd Leininger Testing, Tutorial Leave a Comment

When working with RxJS observables, it can get a little tricky to unit test. Sometimes it can be hard to get insight into what is going on with the observable in the test. I’ve personally been frustrated numerous times by trying to test my observables with the subscribe and assert method. This is where marble testing can make testing observables easier.

The main advantage of using marble testing is the marble diagrams. With the diagrams, we have a visual representation of our observables and subscriptions so we can see the interactions between the two. Once the basics are understood, you should be able to get observable tests running in no time.

In this post, I will show you how to get started using Marble testing with an example. By the end, you should have enough information to get started on your journey testing observables. My examples are based on an Angular application using Jasmine, but these can also be applied to different testing frameworks for React and other applications.

Fiddling with RxJs Streams

Lou Mauget JavaScript, Technology Snapshot Leave a Comment

Egon: Don’t cross the streams. Peter: Why? Egon: It would be bad. – Ghostbusters (1984) In this post I’ll touch on the emergence of JavaScript reactive streams. We’ll look at a cool online interactive tool that is useful for checking behavior of stream operators. I’ll finish by showing six RxJs JSFiddle examples that you can run and modify. Background Rich …