aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/harness.ts8
-rw-r--r--test/js/bun/net/socket.test.ts4
-rw-r--r--test/js/bun/net/tcp-server.test.ts4
-rw-r--r--test/js/bun/stream/direct-readable-stream.test.tsx4
-rw-r--r--test/js/node/events/event-emitter.test.ts2
5 files changed, 13 insertions, 9 deletions
diff --git a/test/harness.ts b/test/harness.ts
index b3932129d..c82ecf698 100644
--- a/test/harness.ts
+++ b/test/harness.ts
@@ -1,6 +1,5 @@
import { gc as bunGC, unsafe } from "bun";
import { heapStats } from "bun:jsc";
-import { expect } from "bun:test";
export const bunEnv: any = {
...process.env,
@@ -30,7 +29,12 @@ export function gc(force = true) {
* @param maxWait
* @returns
*/
-export async function expectMaxObjectTypeCount(type: string, count: number, maxWait = 1000) {
+export async function expectMaxObjectTypeCount(
+ expect: typeof import("bun:test").expect,
+ type: string,
+ count: number,
+ maxWait = 1000,
+) {
gc();
if (heapStats().objectTypeCounts[type] <= count) return;
gc(true);
diff --git a/test/js/bun/net/socket.test.ts b/test/js/bun/net/socket.test.ts
index 7f509966a..f6b90db00 100644
--- a/test/js/bun/net/socket.test.ts
+++ b/test/js/bun/net/socket.test.ts
@@ -90,7 +90,7 @@ it("should reject on connection error, calling both connectError() and rejecting
});
it("should not leak memory when connect() fails", async () => {
- await expectMaxObjectTypeCount("TCPSocket", 1, 100);
+ await expectMaxObjectTypeCount(expect, "TCPSocket", 1, 100);
});
// this also tests we mark the promise as handled if connectError() is called
@@ -132,5 +132,5 @@ it("should handle connection error", done => {
});
it("should not leak memory when connect() fails again", async () => {
- await expectMaxObjectTypeCount("TCPSocket", 1, 100);
+ await expectMaxObjectTypeCount(expect, "TCPSocket", 1, 100);
});
diff --git a/test/js/bun/net/tcp-server.test.ts b/test/js/bun/net/tcp-server.test.ts
index cf7639ecf..95d8cbcf8 100644
--- a/test/js/bun/net/tcp-server.test.ts
+++ b/test/js/bun/net/tcp-server.test.ts
@@ -267,6 +267,6 @@ describe("tcp socket binaryType", () => {
it("should not leak memory", async () => {
// assert we don't leak the sockets
// we expect 1 because that's the prototype / structure
- await expectMaxObjectTypeCount("Listener", 1);
- await expectMaxObjectTypeCount("TCPSocket", 1);
+ await expectMaxObjectTypeCount(expect, "Listener", 1);
+ await expectMaxObjectTypeCount(expect, "TCPSocket", 1);
});
diff --git a/test/js/bun/stream/direct-readable-stream.test.tsx b/test/js/bun/stream/direct-readable-stream.test.tsx
index f310ffbca..9687e4082 100644
--- a/test/js/bun/stream/direct-readable-stream.test.tsx
+++ b/test/js/bun/stream/direct-readable-stream.test.tsx
@@ -237,7 +237,7 @@ describe("ReactDOM", () => {
server?.stop(true);
}
})();
- await expectMaxObjectTypeCount("ReadableHTTPResponseSinkController", 2);
+ await expectMaxObjectTypeCount(expect, "ReadableHTTPResponseSinkController", 2);
});
const count = 4;
it(`http server, ${count} requests`, async () => {
@@ -267,7 +267,7 @@ describe("ReactDOM", () => {
}
})();
expect(remain).toBe(-1);
- await expectMaxObjectTypeCount("ReadableHTTPResponseSinkController", 3);
+ await expectMaxObjectTypeCount(expect, "ReadableHTTPResponseSinkController", 3);
});
});
}
diff --git a/test/js/node/events/event-emitter.test.ts b/test/js/node/events/event-emitter.test.ts
index b6581098a..e397faaed 100644
--- a/test/js/node/events/event-emitter.test.ts
+++ b/test/js/node/events/event-emitter.test.ts
@@ -159,5 +159,5 @@ test("EventEmitter GCs", async () => {
myEmitter.emit("foo");
})();
- await expectMaxObjectTypeCount("EventEmitter", startCount);
+ await expectMaxObjectTypeCount(expect, "EventEmitter", startCount);
});