rxjsjasminekarma-jasminejasmine-marbles

Jasmine tests always failing in RxJS 7 when using toBeObservable()


I've updated my dependencies and am now confronted with this error message:

DEPRECATION: The matcher factory for "toBeObservable" accepts custom equality testers, but this parameter will no longer be passed in a future release. See <https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#matchers-cet> for details.

Error: Expected $[0].notification to be a kind of Object, but was Notification({ kind: 'N', value: true, error: undefined, hasValue: true }).
            at <Jasmine>
            at toBeObservableComparer (node_modules/jasmine-marbles/es6/index.js:80:1)
            at <Jasmine>

The test is very simple:

const expected = cold('a', {a: true});
expect(new BehaviorSubject(true)).toBeObservable(expected);

It might have to do something with the deprecation notice, but I'm just using toBeObservable() from latest version of the jasmine-marbles package and can't see a custom parameter. Also I don't understand why Notification isn't a kind of Object.

Versions:

The script works on rxjs 6.6.7.


Solution

  • I think the new documentation shows the new expectObservable:

    expectObservable(new BehaviorSubject(true).asObservable()).toBe(expected);
    

    Check out the documentation here: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/testing/marble-testing.md#marble-syntax