diff --git a/test/index.test.ts b/test/index.test.ts index a64cddd..f0ff0af 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -9,14 +9,14 @@ import { } from "h3"; import { Blob } from "fetch-blob"; import { FormData } from "formdata-polyfill/esm.min.js"; -import { describe, beforeEach, afterEach, it, expect } from "vitest"; +import { describe, beforeAll, afterAll, it, expect } from "vitest"; import { Headers, $fetch } from "../src/node"; describe("ofetch", () => { let listener; const getURL = (url) => joinURL(listener.url, url); - beforeEach(async () => { + beforeAll(async () => { const app = createApp() .use( "/ok", @@ -24,23 +24,23 @@ describe("ofetch", () => { ) .use( "/params", - eventHandler((event) => getQuery(event.req.url || "")) + eventHandler((event) => getQuery(event.node.req.url || "")) ) .use( "/url", - eventHandler((event) => event.req.url) + eventHandler((event) => event.node.req.url) ) .use( "/post", eventHandler(async (event) => ({ body: await readBody(event), - headers: event.req.headers, + headers: event.node.req.headers, })) ) .use( "/binary", eventHandler((event) => { - event.res.setHeader("Content-Type", "application/octet-stream"); + event.node.res.setHeader("Content-Type", "application/octet-stream"); return new Blob(["binary"]); }) ) @@ -51,7 +51,7 @@ describe("ofetch", () => { listener = await listen(toNodeListener(app)); }); - afterEach(async () => { + afterAll(async () => { await listener.close(); });