@@ -32,6 +32,8 @@ test.after('cleanup', async () => {
3232 await server . closeAsync ( ) ;
3333} ) ;
3434
35+ const nodejsMajorVersion = Number ( process . versions . node . split ( '.' ) [ 0 ] ) ;
36+
3537const error = 'Simple error' ;
3638
3739const makeRequest = ( url = 'https://httpbin.org/anything' , options : http . RequestOptions = { agent : false } ) : { request : ClientRequest ; timings : Timings } => {
@@ -205,13 +207,23 @@ test.cb('sets `total` on abort - after `response` event', t => {
205207 request . once ( 'response' , response => {
206208 request . abort ( ) ;
207209
208- response . once ( 'end' , ( ) => {
209- t . is ( typeof timings . abort , 'number' ) ;
210- t . is ( timings . phases . total , timings . end ! - timings . start ) ;
211- t . truthy ( ( request as any ) . res ) ;
212-
213- t . end ( ) ;
214- } ) ;
210+ if ( nodejsMajorVersion >= 13 ) {
211+ process . nextTick ( ( ) => {
212+ t . is ( typeof timings . abort , 'number' ) ;
213+ t . is ( timings . phases . total , timings . abort ! - timings . start ) ;
214+ t . truthy ( ( request as any ) . res ) ;
215+
216+ t . end ( ) ;
217+ } ) ;
218+ } else {
219+ response . once ( 'end' , ( ) => {
220+ t . is ( typeof timings . abort , 'number' ) ;
221+ t . is ( timings . phases . total , timings . end ! - timings . start ) ;
222+ t . truthy ( ( request as any ) . res ) ;
223+
224+ t . end ( ) ;
225+ } ) ;
226+ }
215227 } ) ;
216228} ) ;
217229
0 commit comments