Playwright testing with Server Side Fetches #5145
Unanswered
mabentley85
asked this question in
Q&A
Replies: 3 comments 2 replies
-
Any updates here? |
Beta Was this translation helpful? Give feedback.
1 reply
-
You can use tools like mswjs to mock your servercalls. |
Beta Was this translation helpful? Give feedback.
1 reply
-
I wrote a package to do this. The setup is more involved than I would like, but it solved my issue with Playwright tests hitting production API requests during E2E tests. https://github.com/markjaquith/sveltekit-playwright-fetch-mock |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When running Playwright tests, setting up mock API routes is pretty straight forward as per this simple example test:
When testing the page below it runs fine, as the API request is run in the browser:
But with this page, the test times out, as it's looking for the actual URL and is not intercepted by the mock API endpoint:
Are there any ways to configure Playwright and/or SvelteKit in order to intercept server side fetches so that mock data is returned?
Beta Was this translation helpful? Give feedback.
All reactions