@@ -449,28 +449,29 @@ describe('supports http with nodejs', function () {
449449 } ) ;
450450 } ) ;
451451
452- it ( 'should wrap HTTP errors and keep stack' , function ( done ) {
452+ it ( 'should wrap HTTP errors and keep stack' , async function ( ) {
453453 if ( nodeMajorVersion <= 12 ) {
454454 this . skip ( ) ; // node 12 support for async stack traces appears lacking
455455 return ;
456456 }
457- server = http . createServer ( function ( req , res ) {
457+
458+ server = await startHTTPServer ( ( req , res ) => {
458459 res . statusCode = 400 ;
459460 res . end ( ) ;
460- } ) . listen ( 4444 , function ( ) {
461- void assert . rejects (
462- async function findMeInStackTrace ( ) {
463- await axios . head ( 'http://localhost:4444/one' )
464- } ,
465- function ( err ) {
466- assert . equal ( err . name , 'AxiosError' )
467- assert . equal ( err . isAxiosError , true )
468- const matches = [ ...err . stack . matchAll ( / f i n d M e I n S t a c k T r a c e / g) ]
469- assert . equal ( matches . length , 1 , err . stack )
470- return true ;
471- }
472- ) . then ( done ) . catch ( done ) ;
473461 } ) ;
462+
463+ return assert . rejects (
464+ async function findMeInStackTrace ( ) {
465+ await axios . head ( 'http://localhost:4444/one' )
466+ } ,
467+ function ( err ) {
468+ assert . equal ( err . name , 'AxiosError' )
469+ assert . equal ( err . isAxiosError , true )
470+ const matches = [ ...err . stack . matchAll ( / f i n d M e I n S t a c k T r a c e / g) ]
471+ assert . equal ( matches . length , 1 , err . stack )
472+ return true ;
473+ }
474+ )
474475 } ) ;
475476
476477 it ( 'should wrap interceptor errors and keep stack' , function ( done ) {
0 commit comments