This commit is contained in:
2026-02-10 02:06:54 +01:00
parent 5290560d68
commit ef5e98ad5d
29 changed files with 1529 additions and 8 deletions

7
test/mocks/handlers.ts Normal file
View 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
View 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
View 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()
})