restoreHandlers()
Marks all used one-time request handlers as unused, allowing them to affect network again.
Examples
1import { rest } from 'msw'2import { setupServer } from 'msw/node'34const server = setupServer(5 rest.get('/book/:bookId', (req, res, ctx) => {6 return res(ctx.json({ title: 'Lord of the Rings' }))7 }),8)910beforeAll(() => {11 server.listen()12})1314afterAll(() => {15 server.close()16})1718test('handles server error gracefully', () => {19 server.use(20 rest.get('/book/:bookId', (req, res, ctx) => {21 return res.once(22 ctx.status(500),23 ctx.json({ message: 'Internal server error' }),24 )25 }),26 )2728 // Assert your application's behavior given server error.29})3031test('renders book detail', () => {32 // At this point the server error request handler has been used,33 // and will not affect network anymore.34})3536test('handles server error when I posted a book review', () => {37 // Restore one-time request handlers.38 // A "GET /book/:bookId" request will return a mocked server error39 // only for the next book detail request.40 server.restoreHandlers()41})