Todo
This commit is contained in:
7
test/mocks/handlers.ts
Normal file
7
test/mocks/handlers.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { HttpResponse, http } from "msw"
|
||||
|
||||
export const handlers = [
|
||||
http.get("https://example.test/health", () => {
|
||||
return HttpResponse.json({ ok: true })
|
||||
}),
|
||||
]
|
||||
5
test/mocks/server.ts
Normal file
5
test/mocks/server.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { setupServer } from "msw/node"
|
||||
|
||||
import { handlers } from "./handlers"
|
||||
|
||||
export const server = setupServer(...handlers)
|
||||
17
test/setup/global.ts
Normal file
17
test/setup/global.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import "@testing-library/jest-dom/vitest"
|
||||
|
||||
import { afterAll, afterEach, beforeAll } from "vitest"
|
||||
|
||||
import { server } from "../mocks/server"
|
||||
|
||||
beforeAll(() => {
|
||||
server.listen({ onUnhandledRequest: "error" })
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
server.resetHandlers()
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
server.close()
|
||||
})
|
||||
Reference in New Issue
Block a user