Angular 7 | RxJS : Test finalize()

In the following interceptor, I want to test if the method 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...

Comments

  1. 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

    ReplyDelete
    Replies
    1. https://codecraft.tv/courses/angular/unit-testing/asynchronous/

      Delete

Post a Comment

Popular posts from this blog

Spring JPA : Using Specification with Projection

Chip input using Reactive Form