ReactiveX / rxjs

A reactive programming library for JavaScript
https://rxjs.dev
Apache License 2.0
30.71k stars 3k forks source link

Problems testing observables that emit arrays or objects with other observables. #6243

Open fcostarodrigo opened 3 years ago

fcostarodrigo commented 3 years ago

Bug Report

Current Behavior When using expectObservable to check an observable that emits and object with some observable the test fails.

Expected behavior The test should pass.

Reproduction That can be 100% reproduced using the code below.

const highOrderObj = of({ a: of('a') });

it('generate the stream correctly', () => {
  testScheduler.run(({ cold, expectObservable }) => {
    expectObservable(highOrderObj).toBe('(a|)', { a: { a: cold('(a|)') } });
  });
});

Environment

voliva commented 3 years ago

I'm not sure this is to be considered a bug, but maybe a feature request?

highOrderObj is a stream that emits objects - In a way I would expect for that to just deeply compare both objects (the expected and the result), but now one of the property of that object is an observable.

I'd like to have this feature, I think it makes sense. But I wouldn't consider it a bug

fcostarodrigo commented 3 years ago

I was not sure as well if it was a bug or a feature. Since it works for of(of('a')) I was thinking it would be a bug. But working for of(of('a')) could be a coincidence.