Acquiring access token crashes test. #549
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Hey. @ErlendLygre! Thank you for the kind words! Please, could you share some code snippets or, ideally, a minimal reproduction repo with this issue? That'd help us to get to the bottom of it much more efficiently.
Does the crash happen because of a failed token request, or there's something else? An error stack trace would be good to see. |
Beta Was this translation helpful? Give feedback.
-
I was able to solve this by mocking the auth service with jest.mock('../../../../../services/authService'); and creating a mock directory with an authService.ts-file containing export const getAccessToken = () => { I'm new to mocking, and didn't realize I could mock an import of an import. |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing the screenshots, they are of great help.
Yes, you can. However, I'd rather you didn't. When you mock an entire I'll try to look into your use case once I have a spare minute. Meanwhile, anybody else is welcome to investigate! |
Beta Was this translation helpful? Give feedback.
-
@ErlendLygre, what happens if you remove the axios.interceptors.reques.use(async (request) => {
try {
- const token = await auth.getAccessToken()
+ const token = 'abc-123'
}
}) Let's simplify the usage example to see if |
Beta Was this translation helpful? Give feedback.
Hey. @ErlendLygre! Thank you for the kind words!
Please, could you share some code snippets or, ideally, a minimal reproduction repo with this issue? That'd help us to get to the bottom of it much more efficiently.
Does the crash happen because of a failed token request, or there's something else? An error stack trace would be good to see.