Skip to content

Commit

Permalink
Get unit tests passing against Node.js 14.
Browse files Browse the repository at this point in the history
This does not cover every possible permutation between v8 and v14.

One difference was traced to nodejs/node#28140 in v13.
  • Loading branch information
jturner-22 committed Nov 9, 2022
1 parent 8d98368 commit 7131146
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions test/util/error-handling-test.ts
Expand Up @@ -8,6 +8,8 @@ import * as assert from 'assert';
import * as Promise from 'bluebird';
import * as http from 'http';
import { ResponseErrorMessages, StatusCodeMessages, handleErrorResponse } from '../../src/util/error-handling';
import * as process from 'process';
import * as SemVer from 'semver';


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

// Node keeps changing the error object.
var expectedError = SemVer.gte(process.version, '14.0.0') ?
{
"code": "ENOTFOUND",
"errno": -3008, // this changed in 13.0.0 (https://github.com/nodejs/node/pull/28140)
"syscall": "getaddrinfo",
"hostname": "999.999.999.999",
"message": "getaddrinfo ENOTFOUND 999.999.999.999"
}
:
{
"code": "ENOTFOUND",
"errno": "ENOTFOUND",
"syscall": "getaddrinfo",
"hostname": "999.999.999.999",
"host": "999.999.999.999",
"port": 443,
"message": "getaddrinfo ENOTFOUND 999.999.999.999 999.999.999.999:443"
};

// Confirm the REQUEST error
should(errorSpy.firstCall.args[1].reqError).be.match({
"code": "ENOTFOUND",
"errno": "ENOTFOUND",
"syscall": "getaddrinfo",
"hostname": "999.999.999.999",
"host": "999.999.999.999",
"port": 443,
"message": "getaddrinfo ENOTFOUND 999.999.999.999 999.999.999.999:443"
});
should(errorSpy.firstCall.args[1].reqError).be.match(expectedError);

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

0 comments on commit 7131146

Please sign in to comment.