@@ -8,6 +8,8 @@ import * as assert from 'assert';
88import * as Promise from 'bluebird' ;
99import * as http from 'http' ;
1010import { ResponseErrorMessages , StatusCodeMessages , handleErrorResponse } from '../../src/util/error-handling' ;
11+ import * as process from 'process' ;
12+ import * as SemVer from 'semver' ;
1113
1214
1315describe ( '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