Is there a way to test observable in a function arguments?
Is there any thing like expect(someObj.foo).ToHaveBeenCalledWithObservable(cold('a|', {a: 1}))
?
I don't think there is something that like that but you can maybe take advantage of callFake
and toBeObservable
.
We callFake
and associate a local variable to the argument that was used.
Then we assert the localVariable toBeObservable
of your expecation.
let argumentForFoo: Observable<any>;
spyOn(someObj.foo).and.callFake(argument => argumentForFoo = argument);
// make sure someObj.foo gets called somewhere here so the callFake can run.
expect(argumentForFoo).toBeObservable(/*...*/);