From ec8fb81487d125604a06cf996a76530042f34f53 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Sun, 12 Dec 2021 12:19:45 -0800 Subject: [PATCH] test: make existing test more resilient without changing its logic --- tests/test_client_request.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_client_request.js b/tests/test_client_request.js index ed1a684cf..c9360e581 100644 --- a/tests/test_client_request.js +++ b/tests/test_client_request.js @@ -108,11 +108,13 @@ describe('Direct use of `ClientRequest`', () => { it('should emit an expected error when no interceptors and net connect is disallowed', done => { nock.disableNetConnect() - new http.ClientRequest({ port: 12345, path: '/' }).on('error', err => { - expect(err.message).to.equal( - 'Nock: Disallowed net connect for "localhost:12345/"' - ) - done() - }) + new http.ClientRequest({ port: 12345, path: '/' }) + .on('error', err => { + expect(err.message).to.equal( + 'Nock: Disallowed net connect for "localhost:12345/"' + ) + done() + }) + .on('close', done(new Error('Should not permit to connect'))) }) })