Skip to content
Discussion options

You must be logged in to vote

Hi, @Sethuraman. Afaik, it's a bad idea to nest before* and after* hooks in utility functions. You're making it much harder for your testing framework to apply then. That's likely the root cause for this intermittence. Move them out on the root level setupTest.ts and instead reuse the same server instance if you want a helper like makeServer(). We are showcasing that setup in the Node.js integration in the docs.

The second mistake I've spotted in your code is that you're adding server.use() overrides after render(). By doing that, you are welcoming a race condition between your component rendering and MSW learning about your request handlers. Please add those overrides before your render …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kettanaito
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants