mirror of
https://github.com/hanzoai/msw.git
synced 2026-09-24 17:00:34 +00:00
24 lines
536 B
TypeScript
24 lines
536 B
TypeScript
// @vitest-environment node
|
|
import { setupServer } from 'msw/node'
|
|
import { HttpResponse, http } from 'msw'
|
|
|
|
const server = setupServer(
|
|
http.get('https://test.mswjs.io/pull', () => {
|
|
return HttpResponse.json({ status: 'pulled' })
|
|
}),
|
|
)
|
|
|
|
beforeAll(() => server.listen())
|
|
afterAll(() => server.close())
|
|
|
|
test('tolerates fake timers', async () => {
|
|
vi.useFakeTimers()
|
|
|
|
const res = await fetch('https://test.mswjs.io/pull')
|
|
const body = await res.json()
|
|
|
|
vi.useRealTimers()
|
|
|
|
expect(body).toEqual({ status: 'pulled' })
|
|
})
|