title: Mocking back-end 3rd-party calls in Sveltekit + Playwright
body: <p>This is a fairly high-level question regarding design patterns/best practices when developing end-to-end tests in SvelteKit+Playwright:</p>
  <p><strong>What is the recommended way of ensuring that any back-end code that makes a call to a 3rd-party system is stubbed/mocked during e2e Playwright tests?</strong></p>
  <p>In my particular case, I have defined my <code>hooks.js</code> file to redirect users to a 3rd-party login services the moment a user attempts to access a restricted URL. I would like to test the <code>hook.js</code> file as part of my e2e tests, but I don't want it to hit the 3rd-party service each time. I would like to apply this pattern to a similar problem I will have when testing flows that involve back-end calls to AWS S3.</p>
  <p>I know that Playwright allows you to mock network calls performed by the client, but I haven't read of similar capabilities for server-side calls.</p>
  <p>Is there a way where I can intercept the outgoing calls triggered by <code>hooks.js</code> and other back-end handlers?</p>