diff --git a/docs/guide/mocking.md b/docs/guide/mocking.md index e5abbc84f..69e1c19d8 100644 --- a/docs/guide/mocking.md +++ b/docs/guide/mocking.md @@ -277,7 +277,7 @@ You can use it like below in your [setup file](/config/#setupfiles) ```js import { afterAll, afterEach, beforeAll } from 'vitest' import { setupServer } from 'msw/node' -import { graphql, rest } from 'msw' +import { HttpResponse, graphql, rest } from 'msw' const posts = [ { @@ -290,14 +290,18 @@ const posts = [ ] export const restHandlers = [ - rest.get('https://rest-endpoint.example/path/to/posts', (req, res, ctx) => { - return res(ctx.status(200), ctx.json(posts)) + http.get('https://rest-endpoint.example/path/to/posts', () => { + return HttpResponse.json(posts) }), ] const graphqlHandlers = [ - graphql.query('https://graphql-endpoint.example/api/v1/posts', (req, res, ctx) => { - return res(ctx.data(posts)) + graphql.query('https://graphql-endpoint.example/api/v1/posts', () => { + return HttpResponse.json( + { + data: { posts }, + }, + ) }), ]