@@ -1013,22 +1013,40 @@ describe('Boom', () => {
10131013
10141014 describe ( 'stack trace' , ( ) => {
10151015
1016+ const helpers = [ 'badRequest' , 'unauthorized' , 'forbidden' , 'notFound' , 'methodNotAllowed' ,
1017+ 'notAcceptable' , 'proxyAuthRequired' , 'clientTimeout' , 'conflict' ,
1018+ 'resourceGone' , 'lengthRequired' , 'preconditionFailed' , 'entityTooLarge' ,
1019+ 'uriTooLong' , 'unsupportedMediaType' , 'rangeNotSatisfiable' , 'expectationFailed' ,
1020+ 'badData' , 'preconditionRequired' , 'tooManyRequests' ,
1021+
1022+ // 500s
1023+ 'internal' , 'notImplemented' , 'badGateway' , 'serverUnavailable' ,
1024+ 'gatewayTimeout' , 'badImplementation'
1025+ ] ;
1026+
10161027 it ( 'should omit lib' , ( ) => {
10171028
1018- [ 'badRequest' , 'unauthorized' , 'forbidden' , 'notFound' , 'methodNotAllowed' ,
1019- 'notAcceptable' , 'proxyAuthRequired' , 'clientTimeout' , 'conflict' ,
1020- 'resourceGone' , 'lengthRequired' , 'preconditionFailed' , 'entityTooLarge' ,
1021- 'uriTooLong' , 'unsupportedMediaType' , 'rangeNotSatisfiable' , 'expectationFailed' ,
1022- 'badData' , 'preconditionRequired' , 'tooManyRequests' ,
1029+ for ( const helper of helpers ) {
1030+ const err = Boom [ helper ] ( ) ;
1031+ expect ( err . stack ) . to . not . match ( / \/ l i b \/ i n d e x \. j s / ) ;
1032+ }
1033+ } ) ;
10231034
1024- // 500s
1025- 'internal' , 'notImplemented' , 'badGateway' , 'serverUnavailable' ,
1026- 'gatewayTimeout' , 'badImplementation'
1027- ] . forEach ( ( name ) => {
1035+ it ( 'should not crash when Error.captureStackTrace is missing' , ( flags ) => {
10281036
1029- const err = Boom [ name ] ( ) ;
1030- expect ( err . stack ) . to . not . match ( / \/ l i b \/ i n d e x \. j s / ) ;
1031- } ) ;
1037+ const captureStackTrace = Error . captureStackTrace ;
1038+
1039+ for ( const helper of helpers ) {
1040+ try {
1041+ Error . captureStackTrace = undefined ;
1042+ var err = Boom [ helper ] ( ) ;
1043+ }
1044+ finally {
1045+ Error . captureStackTrace = captureStackTrace ;
1046+ }
1047+
1048+ expect ( err . stack ) . to . match ( / \/ l i b \/ i n d e x \. j s / ) ;
1049+ }
10321050 } ) ;
10331051 } ) ;
10341052
0 commit comments