From 133b0045fc445af7f8f2829d03fd10bf43ad668c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 16 Oct 2024 11:30:17 -0700 Subject: [PATCH] Fix test --- test/js/bun/http/serve.test.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/test/js/bun/http/serve.test.ts b/test/js/bun/http/serve.test.ts index 1376c0a1c1..c1581c24e0 100644 --- a/test/js/bun/http/serve.test.ts +++ b/test/js/bun/http/serve.test.ts @@ -499,27 +499,22 @@ describe("streaming", () => { }); it("throw on pull after writing should not call the error handler", async () => { - let subprocess; - - afterAll(() => { - subprocess?.kill(); - }); - - const onMessage = mock(async href => { + var onMessage = mock(async href => { const url = new URL("write", href); const response = await fetch(url); expect(response.status).toBe(402); expect(response.headers.get("X-Hey")).toBe("123"); - expect(response.text()).resolves.toBe(""); + expect(await response.text()).toBe(""); subprocess.kill(); }); - subprocess = Bun.spawn({ + await using subprocess = Bun.spawn({ cwd: import.meta.dirname, cmd: [bunExe(), "readable-stream-throws.fixture.js"], env: bunEnv, stdout: "ignore", stderr: "pipe", + stdin: "inherit", ipc: onMessage, }); @@ -2053,5 +2048,5 @@ it("allow custom timeout per request", async () => { expect(server.timeout).toBeFunction(); const res = await fetch(new URL("/long-timeout", server.url.origin)); expect(res.status).toBe(200); - expect(res.text()).resolves.toBe("Hello, World!"); + expect(await res.text()).toBe("Hello, World!"); }, 20_000);