This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| language: TypeScript | |
| id: missing-done-callback-in-subscribe | |
| message: When subscribing to an observable inside a test function, you must call the 'done' function. Otherwise the assertions will never run. | |
| severity: error | |
| note: | | |
| When testing observables in Jest, you must call the `done()` function in the subscribe callback. Jest provides a `done` function to test functions that must be executed to let Jest know when the test is done. | |
| If you don't call the done function, the assertions will never run because Jest will finish the test before the subscribe callback is called. | |
| If possible, it is encouraged to use `firstValueFrom` or `lastValueFrom` instead of subscribing to an observable directly in a test function. These handle subscribing / unsubscribing for you. |
OlderNewer