initial commit
This commit is contained in:
commit
88c14b627e
224 files changed
+17204
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { setupServer } from "msw/node";
|
||||
import { afterAll, afterEach, beforeAll, expect, it, vi } from "vitest";
|
||||
import { getHealthz } from "./endpoints/health/health";
|
||||
import { getHealthMock } from "./endpoints/health/health.msw";
|
||||
import { HealthResponse } from "./schemas";
|
||||
|
||||
const server = setupServer(...getHealthMock());
|
||||
|
||||
beforeAll(() => server.listen({ onUnhandledFrame: "error" }));
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
server.resetHandlers();
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
it("serves the generated client through the generated MSW handler", async () => {
|
||||
const interceptedFetch = globalThis.fetch;
|
||||
// Node has no document origin for the browser client's relative URLs.
|
||||
vi.stubGlobal("fetch", (input: string, init?: RequestInit) =>
|
||||
interceptedFetch(new URL(input, "http://localhost"), init),
|
||||
);
|
||||
|
||||
const response = await getHealthz();
|
||||
|
||||
expect(HealthResponse.parse(response)).toEqual({ status: "ok" });
|
||||
});
|
||||
Reference in new issue
Block a user