MSW needs multiple flushPromises() #1347
Replies: 3 comments
-
Have the same behavior, any idea ? |
Beta Was this translation helpful? Give feedback.
-
Yeah for now I'm using https://github.com/sindresorhus/p-wait-for too |
Beta Was this translation helpful? Give feedback.
-
So in the last 2 weeks there were discussions about this in couple of different places, so for anybody interested here are some links:
So in short - this isn't changing on MSW's side, probably we're going to get something like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everybody 🙂 I have kind of "strange" behavior when we use MSW for mocking the rest calls - we need to use multiple await flushPromises() so the component is correctly mounted. We are using Vitest, but this is an issue other colleagues have faced with Vue 2 + Jest.
Although having 2 or 3
flushPromises
isn't a deal breaker, the amount of calls is always different and we can't really have a stable testing experience... Why exactly do we have such behaviour and a singleawait flushPromises
isn't enough? Is this something fromvue-test-utils
side or strictlymsw
related?I've uploaded an example project with this here https://github.com/simeon-petrov-5/vue-testing-script-setup
I found that other people also had such experience discussed at MSW, but no answer was found mswjs/msw#988
Component example
Test example
Workarounds I found are
mock-axios-adapter
- a singleawait flushPromises()
is all we need and works as I would expectI would be very thankful if someone had such situation and/or can shine some light ^^ If this is "normal" I guess a comment for MSW usage with this retry-implementation from the article will be helpful for others too.
Beta Was this translation helpful? Give feedback.
All reactions