Skip to content

Commit 7131146

Browse files
committed
Get unit tests passing against Node.js 14.
This does not cover every possible permutation between v8 and v14. One difference was traced to nodejs/node#28140 in v13.
1 parent 8d98368 commit 7131146

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

test/util/error-handling-test.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import * as assert from 'assert';
88
import * as Promise from 'bluebird';
99
import * as http from 'http';
1010
import { ResponseErrorMessages, StatusCodeMessages, handleErrorResponse } from '../../src/util/error-handling';
11+
import * as process from 'process';
12+
import * as SemVer from 'semver';
1113

1214

1315
describe('Error Handling', function () {
@@ -181,16 +183,28 @@ describe('Error Handling', function () {
181183
// Check that the error was sent to the node.
182184
should(errorSpy.firstCall.args[0]).be.eql('Address not found. Error code: ENOTFOUND from system call "getaddrinfo"');
183185

186+
// Node keeps changing the error object.
187+
var expectedError = SemVer.gte(process.version, '14.0.0') ?
188+
{
189+
"code": "ENOTFOUND",
190+
"errno": -3008, // this changed in 13.0.0 (https://github.com/nodejs/node/pull/28140)
191+
"syscall": "getaddrinfo",
192+
"hostname": "999.999.999.999",
193+
"message": "getaddrinfo ENOTFOUND 999.999.999.999"
194+
}
195+
:
196+
{
197+
"code": "ENOTFOUND",
198+
"errno": "ENOTFOUND",
199+
"syscall": "getaddrinfo",
200+
"hostname": "999.999.999.999",
201+
"host": "999.999.999.999",
202+
"port": 443,
203+
"message": "getaddrinfo ENOTFOUND 999.999.999.999 999.999.999.999:443"
204+
};
205+
184206
// Confirm the REQUEST error
185-
should(errorSpy.firstCall.args[1].reqError).be.match({
186-
"code": "ENOTFOUND",
187-
"errno": "ENOTFOUND",
188-
"syscall": "getaddrinfo",
189-
"hostname": "999.999.999.999",
190-
"host": "999.999.999.999",
191-
"port": 443,
192-
"message": "getaddrinfo ENOTFOUND 999.999.999.999 999.999.999.999:443"
193-
});
207+
should(errorSpy.firstCall.args[1].reqError).be.match(expectedError);
194208

195209
// Check that the node's status was set.
196210
should(node.getStatus()).match({

0 commit comments

Comments
 (0)