mirror of
https://github.com/hanzoai/msw.git
synced 2026-09-24 17:00:34 +00:00
17 lines
507 B
TypeScript
17 lines
507 B
TypeScript
import { test, expect } from '../playwright.extend'
|
|
|
|
test('mocks response to a GET request', async ({ loadExample, fetch }) => {
|
|
await loadExample(new URL('./basic.mocks.ts', import.meta.url))
|
|
|
|
const response = await fetch('https://example.com/users/octocat')
|
|
const status = response.status()
|
|
const body = await response.json()
|
|
|
|
expect(status).toBe(200)
|
|
expect(response.fromServiceWorker()).toBe(true)
|
|
expect(body).toEqual({
|
|
name: 'John Maverick',
|
|
originalUsername: 'octocat',
|
|
})
|
|
})
|