2

I'm testing an observable that might be described with following diagram:

-a(bcdef) // emit one value at first frame and 5 values in second frame
--g       // emit one value at third frame

But I cannot describe this observable in single diagram, which is expected by function expectObservable().toBe

When I write a diagram like below:

-a(bcdef)g

g appears to be in 9th frame, but I want the value to appear in the 3rd frame.

I also tried to use combineLatest to combine multiple diagrams into single one like below, following this suggestion

const values = {a, b, c, d, e, f, g };
const expected1$ = cold('-a(bcdef)', {a, b, c, d, e, f  });
const expected2$ = cold('--g', { g });

const expected$ = combineLatest([
  expected1$,
  expected2$
]);

but unfortunately I've got an error.

Please advice how to test this case with marbles and if it's even possible to combine expected marbles?

Jonathan Stellwag
  • 3,843
  • 4
  • 25
  • 50
Valentine
  • 506
  • 6
  • 23
  • What error did you get? – NickL Nov 28 '21 at 14:54
  • You can find the error at the screenshot https://prnt.sc/20ydpni The problem is that value of 'g' expected to be in time frame 3 but it comes after parantheses and appears in 9th frame, an when I include value of 'g' into parantheses it appears in frame 2. How to build the diagram to make 'g' be in frame 3? – Valentine Nov 29 '21 at 10:19
  • Could you filter out everything __except for__ g? E.g. `source.pipe(filter(x => x !== 'g'))`. That way you could write `.toBe('---g', ... )` and then do it once again, but filtering for the other values – NickL Nov 29 '21 at 14:58

0 Answers0