valendres / playwright-msw

A Mock Service Worker API for Playwright
MIT License
166 stars 23 forks source link

fix: race condition which breaks compatibility with vue #61

Closed valendres closed 1 year ago

valendres commented 1 year ago

Fixes: https://github.com/valendres/playwright-msw/issues/60

Root cause: It seems there's a race condition with the onload event being fired and the API call being made. In https://github.com/valendres/playwright-msw/pull/47, a change was made so that playwright-msw would not attempt to intercept API calls until this event was fired, with the goal of preventing the interception of the initial HTTP call (the one that should return HTML). While this seemed to solve the issue in React, it likely broke Vue compatibility 😞

Changes:

  1. A minor change to the Router which utilises the first requestfinished event instead of load to detect page load.
  2. Introduction of an example-vue app which ensures that this fix addresses the vue compatibility issue.