diff --git a/test/parallel/test-http-hostname-typechecking.js b/test/parallel/test-http-hostname-typechecking.js index 74813e0582d853..e63af7d3f09ecc 100644 --- a/test/parallel/test-http-hostname-typechecking.js +++ b/test/parallel/test-http-hostname-typechecking.js @@ -18,10 +18,12 @@ vals.forEach((v) => { assert.throws(() => http.request({host: v}), errHost); }); -// These values are OK and should not throw synchronously +// These values are OK and should not throw synchronously. +// Only testing for 'hostname' validation so ignore connection errors. +const dontCare = () => {}; ['', undefined, null].forEach((v) => { assert.doesNotThrow(() => { - http.request({hostname: v}).on('error', () => {}).end(); - http.request({host: v}).on('error', () => {}).end(); + http.request({hostname: v}).on('error', dontCare).end(); + http.request({host: v}).on('error', dontCare).end(); }); });