Great explanation,
I was trying to test my interceptor and I'm acquiring an access token in the interceptor and attach it to the request like this:
`return authService.acquireToken(source).mergeMap(//somecode);
I'm having problem with mergeMap, I'm not sure how to mock this part ?
Any idea ?
I'm a developer, a community builder, and a relentless learner. I'm a Google Developer Expert in Angular, a Pluralsight author, a conference speaker, and a volunteer for women in tech groups. ❤️🍷📚
I'm assuming you are mocking the authService's acquireToken method. If so, you shouldn't need to mock mergeMap.
I don't know your use case, but if the mergeMap is complicated, should it be part of acquireToken (or pulled out differently) so that it can be tested independently? It sounds like you might have a lot going on in the interceptor.
yes, I'm trying to mock the auth service which calls acquireToken method that is part of the adal.js library. Because of the method returns an Observable, so I'm chaining mergeMap to acquireToken in order to wait to get the token.
I will try to take it out of the interceptor to make the test easier.
Thanks again
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great explanation,
I was trying to test my interceptor and I'm acquiring an access token in the interceptor and attach it to the request like this:
`return authService.acquireToken(source).mergeMap(//somecode);
I'm having problem with mergeMap, I'm not sure how to mock this part ?
Any idea ?
Thanks, I'm glad you liked it.
I'm assuming you are mocking the authService's acquireToken method. If so, you shouldn't need to mock mergeMap.
I don't know your use case, but if the mergeMap is complicated, should it be part of acquireToken (or pulled out differently) so that it can be tested independently? It sounds like you might have a lot going on in the interceptor.
Best wishes on your project!
Thank you Alisa,
yes, I'm trying to mock the auth service which calls acquireToken method that is part of the adal.js library. Because of the method returns an Observable, so I'm chaining mergeMap to acquireToken in order to wait to get the token.
I will try to take it out of the interceptor to make the test easier.
Thanks again