cartant / rxjs-marbles

An RxJS marble testing library for any test framework

Home Page:https://cartant.github.io/rxjs-marbles/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with emitted values containg undefined properties

chrisbouchard opened this issue · comments

I have a test like the following:

it(`should fail with a useful error message`, marbles(m => {
    const actual = of([undefined]);
    m.expect(actual).toBeObservable('--|');
}));

I expect the test to fail with a message that the observables don't match, but instead I get an error like:

TypeError: Unable to get property 'replace' of undefined or null reference
   at stringify ...

(I've cut out the stack trace because I'm using webpack). The problem seems to be that stringify in matcher.js does not check if its parameter x is undefined before attempting to format it. Simply checking for undefined and returning 'undefined' makes the test fail correctly.

This does not happen if the emitted value is actually undefined, only if it has an undefined property (or presumably if any of its inner objects do). It also does not happen for tests that pass, regardless of the emitted values.

Thanks. This should be fixed in 2.3.1.