diff options
author | 2023-03-18 16:35:49 -0700 | |
---|---|---|
committer | 2023-03-18 16:35:49 -0700 | |
commit | d9711c64eb0bf4a9ebc232228c6d8ba0d9f495a6 (patch) | |
tree | 880b1e65822c57dea15692deb00f44c297011149 /test/js/node/net/node-net-server.test.ts | |
parent | 96fcecdcc9ebae4c81b0238519eaeb4cca2b9881 (diff) | |
download | bun-d9711c64eb0bf4a9ebc232228c6d8ba0d9f495a6.tar.gz bun-d9711c64eb0bf4a9ebc232228c6d8ba0d9f495a6.tar.zst bun-d9711c64eb0bf4a9ebc232228c6d8ba0d9f495a6.zip |
Make node-net tests less flaky
Diffstat (limited to 'test/js/node/net/node-net-server.test.ts')
-rw-r--r-- | test/js/node/net/node-net-server.test.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/js/node/net/node-net-server.test.ts b/test/js/node/net/node-net-server.test.ts index 063a822d5..e8b5234e6 100644 --- a/test/js/node/net/node-net-server.test.ts +++ b/test/js/node/net/node-net-server.test.ts @@ -336,6 +336,8 @@ it("should call connection and drop", done => { socket.end(); }, }, + }).catch(e => { + closeAndFail(); }); } for (let i = 0; i < maxClients; i++) { @@ -377,7 +379,7 @@ it("should call listening", done => { }); it("should call error", done => { - const { mustCall, mustNotCall } = createCallCheckCtx(done); + const { mustCall, mustNotCall, closeTimers } = createCallCheckCtx(done); let timeout; const server = createServer(); @@ -386,8 +388,8 @@ it("should call error", done => { const closeAndFail = mustNotCall("error not called (timeout)", () => { clearTimeout(timeout); + closeTimers(); server.close(); - done(); }); //should be faster than 100ms @@ -401,6 +403,7 @@ it("should call error", done => { mustCall(err => { server.close(); clearTimeout(timeout); + closeTimers(); expect(err).toBeDefined(); done(); }), @@ -409,7 +412,7 @@ it("should call error", done => { }); it("should call abort with signal", done => { - const { mustCall, mustNotCall } = createCallCheckCtx(done); + const { mustCall, mustNotCall, closeTimers } = createCallCheckCtx(done); const controller = new AbortController(); let timeout; @@ -420,7 +423,6 @@ it("should call abort with signal", done => { const closeAndFail = mustNotCall("close not called (timeout)", () => { clearTimeout(timeout); server.close(); - done(); }); //should be faster than 100ms @@ -432,7 +434,8 @@ it("should call abort with signal", done => { .on( "close", mustCall(() => { - clearImmediate(timeout); + clearTimeout(timeout); + closeTimers(); done(); }), ) @@ -442,7 +445,7 @@ it("should call abort with signal", done => { }); it("should echo data", done => { - const { mustCall, mustNotCall } = createCallCheckCtx(done); + const { mustCall, mustNotCall, closeTimers } = createCallCheckCtx(done); let timeout; const server = createServer(socket => { @@ -470,6 +473,7 @@ it("should echo data", done => { socket: { data(socket, data) { clearTimeout(timeout); + closeTimers(); server.close(); socket.end(); expect(data.byteLength).toBe(5); |