Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passthrough does not work #92

Open
kristojorg opened this issue Feb 28, 2024 · 0 comments
Open

passthrough does not work #92

kristojorg opened this issue Feb 28, 2024 · 0 comments

Comments

@kristojorg
Copy link

kristojorg commented Feb 28, 2024

I have been trying to set up playwright-msw with

  • MSW 2.x
  • playwright-msw 3.0.1
  • @playwright/test 1.42.0

I have noticed that the passthrough function from MSW does not work, and these routes are never completed. I can create my own passthrough function that does work: http.get("*", ({request}) => fetch(request)));, but I would expect the playwright version to work as well.

I've created a reproduction repo here: https://github.com/kristojorg/vite-playwright-msw.git

Steps to reproduce

  1. Clone the repo https://github.com/kristojorg/vite-playwright-msw.git
  2. pnpm install
  3. pnpm dev - this will run the app without MSW running in the browser. The expectation being that when we run playwright against this local server, playwright will intercept requests.
  4. Notice that It shows 100 posts. This is the live value from the API we are fetching data from.
  5. Run pnpm run test. The test will fail because the browser never loaded. It was not able to fetch the requests at http://localhost:5173/* despite the passthrough configured.
  6. Comment out the default MSW passthrough and use the custom passthrough defined below.
  7. Rerun tests. They should now pass
@kristojorg kristojorg changed the title Not intercepting routes passthrough does not work Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant