Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

api-fixture.ts

17 lines592 Bytes

1import { test as base } from '@playwright/test'
2import { defineNetworkFixture } from '@msw/playwright'
3import { apiHandlers } from './api-handlers'
4​
5// Opt in only for suites that consume the canned API. Playwright routing
6// disables HTTP caching; other suites keep their normal browser behavior.
7export const apiTest = base.extend<{ mockApi: void }>({
8 mockApi: [
9 async ({ context }, use) => {
10 const network = defineNetworkFixture({ context, handlers: apiHandlers })
11 await network.enable()
12 await use()
13 await network.disable()
14 },
15 { auto: true },
16 ],
17})