mirror of
https://github.com/hanzoai/msw.git
synced 2026-09-24 17:00:34 +00:00
33 lines
655 B
TypeScript
33 lines
655 B
TypeScript
import { test, expect } from '../playwright.extend'
|
|
import { gql } from '../../support/graphql'
|
|
|
|
test('mocks a GraphQL error response', async ({ loadExample, query }) => {
|
|
await loadExample(new URL('./errors.mocks.ts', import.meta.url))
|
|
|
|
const res = await query('/graphql', {
|
|
query: gql`
|
|
query Login {
|
|
user {
|
|
id
|
|
}
|
|
}
|
|
`,
|
|
})
|
|
const body = await res.json()
|
|
|
|
expect(res.status()).toBe(200)
|
|
expect(body).toEqual({
|
|
errors: [
|
|
{
|
|
message: 'This is a mocked error',
|
|
locations: [
|
|
{
|
|
line: 1,
|
|
column: 2,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
})
|
|
})
|