Skip to content

Commit

Permalink
外部リクエストをモック化
Browse files Browse the repository at this point in the history
  • Loading branch information
shun91 committed Apr 1, 2024
1 parent 100435f commit 37896ba
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/parseTextAndUrl.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { setupServer } from "msw/node";
import { parseTextAndUrl } from "./parseTextAndUrl"; // 適切なパスに置き換えてください
import { test, expect } from "vitest";
import { test, expect, beforeAll, afterAll, afterEach } from "vitest";
import { rest } from "msw";

const server = setupServer(
rest.get("*", (req, res, ctx) => {
return res(ctx.json({ data: "mocked data" }));
})
);

beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

test("URLを含むテキストをパースする", async () => {
const testInput =
Expand Down

0 comments on commit 37896ba

Please sign in to comment.