Open 1010real opened 1 year ago
I suspect this is due to a race condition when registering msw handlers. https://github.com/valendres/playwright-msw/blob/4202f690dadec92324b898c3e209b76257f89641/packages/playwright-msw/src/router.ts#L124-L139
registerMswHandler()
checks to see if there's existing route data, and if not proceeds to initialize it. However, this initialization happens asynchronously (due to L135), so two registrations happening concurrently might both think they're the first and initialize the data.
First, thanks to the contributors.
Because I found a behavior below, I created an issue.
To make it work on playwright, I need to reverse handlers array or overwrite by worker.use on test case. Probably, playwright-msw's routing depends on path only? https://github.com/valendres/playwright-msw/blob/main/packages/playwright-msw/src/router.ts