Writing your first marble test

Let's create a new file marble-testing.spec.ts. It should look like the following:

// marble-testing\MarbleTesting\src\app\marble-testing.spec.tsimport { cold } from "jasmine-marbles";import "rxjs/add/operator/map";describe("marble tests", () => {  it("map - should increase by 1", () => {    const one$ = cold("x-x|", { x: 1 });    expect(one$.map(x => x + 1)).toBeObservable(cold("x-x|", { x: 2 }));  });});

A lot of interesting things are happening here. We import the function cold() from the NPM library marble-testing. Thereafter we set up a test suite by calling describe(), followed by a test specification, by calling it(). Then we call our cold() function and provide it a string. Let's have a close look at that function ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.