Upon returning an object from the Observable, one of its properties is a function.
Even after assigning an empty function and emitting the object, the expectation using toBeObservable
fails due to a non-deep match.
For testing purposes, I am utilizing rxjs-marbles/jest
. Below is a sample test case:
it('...', marbles(m => {
const source = m.cold('(a|)');
const expected = m.cold('(b|)', { b: {
label: 'A',
action: () => { }
} });
const destination = source.pipe(
map(() => ({
label: 'A',
action: () => { }
}))
);
m.expect(destination).toBeObservable(expected);
}));
The outcome looks like this:
expect(received).toEqual(expected) // deep equality
Expected: [{"frame": 0, "notification": {"error": undefined, "hasValue": true, "kind": "N", "value": {"action": [Function action], "label": "A"}}}, {"frame": 0, "notification": {"error": undefined, "hasValue": false, "kind": "C", "value": undefined}}]
Received: serializes to the same string
All I really need to verify is if the action
is defined in the object. Is this achievable?