mirror of
https://github.com/hanzoai/msw.git
synced 2026-09-24 17:00:34 +00:00
27 lines
817 B
TypeScript
27 lines
817 B
TypeScript
import { test, expect } from '../../../playwright.extend'
|
|
|
|
test('responds with a JSON response body', async ({ loadExample, fetch }) => {
|
|
await loadExample(new URL('./body-json.mocks.ts', import.meta.url))
|
|
|
|
const res = await fetch('/json')
|
|
const headers = await res.allHeaders()
|
|
const json = await res.json()
|
|
|
|
expect(headers).toHaveProperty('content-type', 'application/json')
|
|
expect(json).toEqual({ firstName: 'John' })
|
|
})
|
|
|
|
test('responds with a single number JSON response body', async ({
|
|
loadExample,
|
|
fetch,
|
|
}) => {
|
|
await loadExample(new URL('./body-json.mocks.ts', import.meta.url))
|
|
|
|
const res = await fetch('/number')
|
|
const headers = await res.allHeaders()
|
|
const json = await res.json()
|
|
|
|
expect(headers).toHaveProperty('content-type', 'application/json')
|
|
expect(json).toEqual(123)
|
|
})
|