Angular 7 | RxJS : Test finalize()
In the following interceptor, I want to test if the method
As you can see this function is called from the
Thanks for sharing...
loaderService.stopLoading()
is properly called :As you can see this function is called from the
finalize()
RxJS operator. The unit test for this interceptor is as follow:
Thanks for sharing...
This test will still be green, even if startLoading and stopLoading are not called. This is because the stuff that happens in the subscribe and finalize block happen after the test is finished. You should use either async or a done-function
ReplyDeletehttps://codecraft.tv/courses/angular/unit-testing/asynchronous/
Delete