https://medium.com/angular-in-depth/how-to-test-observables-a00038c7faad
excerpt:
The “subscribe and assert pattern” has the following downsides
- You need to remind yourself always to call the
done
callback
1. Don’t forget to call “done” when you’re done ☝️
Often, tests which use the “subscribe and assert pattern” are green even though, in reality, they are failing. How come? 🤔
In asynchronous scenarios, our test rushes through without also checking our assertions inside our
next
,complete
orerror
handler. This can quickly happen if we forget to call thedone
callback after the assertions.The done callback is a way to indicate to the testing framework when our test is actually done.
remarks: forgetting about “done” is elusive because this test passed when it actually failed. However, the karma will return and show you some other test failed if you run ng test. but the other test is actually passing. ng test is not good at reporting precisely.