diff --git a/tests/unit_node/zlib_test.ts b/tests/unit_node/zlib_test.ts index 7e3f97481a..94b1c63cac 100644 --- a/tests/unit_node/zlib_test.ts +++ b/tests/unit_node/zlib_test.ts @@ -44,7 +44,7 @@ Deno.test("gzip compression sync", { sanitizeResources: false }, () => { }); Deno.test("brotli compression", async () => { - const { promise, resolve } = Promise.withResolvers(); + const promise = Promise.withResolvers(); const compress = createBrotliCompress(); const filePath = relative( Deno.cwd(), @@ -61,13 +61,14 @@ Deno.test("brotli compression", async () => { const output2 = createWriteStream("lorem_ipsum.txt"); const stream2 = input2.pipe(decompress).pipe(output2); - - stream2.on("finish", () => { - resolve(); - }); + stream2.on("close", () => promise.resolve()); }); - await promise; + await Promise.all([ + promise.promise, + new Promise((r) => stream.on("close", r)), + ]); + const content = Deno.readTextFileSync("lorem_ipsum.txt"); assert(content.startsWith("Lorem ipsum dolor sit amet")); try {