Playwright testing with Server Side Fetches #5145
Unanswered
mabentley85
asked this question in
Q&A
Replies: 4 comments 3 replies
|
Any updates here? |
1 reply
|
You can use tools like mswjs to mock your servercalls. |
2 replies
|
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 |
0 replies
|
Use MSW as per Spuxx wrote here. @mabentley85 was your question answered yet? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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?
All reactions