The RxJS library's Observer
triggers three main events:
complete
error
next
If we want to verify the occurrence of the complete event using Jest, how can this be achieved?
For instance, we are able to test the next
and error
events by checking for data passed within those functions:
o.subscribe(result => {
expect(result.data.length).toEqual(1);
},
(e)=>{expect(e).toBeFalsy()},
()=>{ WHAT TO EXPECT HERE? }
Unlike the other events, the complete
event does not pass any data. Its function signature is ()=>void
. How can we verify this specific function signature?
Furthermore, regarding the line (e)=>{expect(e).toBeFalsy()}
, since it doesn't actually trigger, is there a way to confirm that a certain callback is not executed?