@@ -542,6 +542,7 @@ describe('Class: Router - Error Handling', () => {
542
542
543
543
it ( 'handles throwing a generic error from the error handler' , async ( ) => {
544
544
// Prepare
545
+ vi . stubEnv ( 'POWERTOOLS_DEV' , 'true' ) ;
545
546
const app = new Router ( ) ;
546
547
547
548
app . errorHandler ( BadRequestError , async ( ) => {
@@ -556,15 +557,13 @@ describe('Class: Router - Error Handling', () => {
556
557
const result = await app . resolve ( createTestEvent ( '/test' , 'GET' ) , context ) ;
557
558
558
559
// Assess
559
- expect ( result ) . toEqual ( {
560
- statusCode : HttpErrorCodes . INTERNAL_SERVER_ERROR ,
561
- body : JSON . stringify ( {
562
- statusCode : HttpErrorCodes . INTERNAL_SERVER_ERROR ,
563
- error : 'Internal Server Error' ,
564
- message : 'Internal Server Error' ,
565
- } ) ,
566
- headers : { 'content-type' : 'application/json' } ,
567
- isBase64Encoded : false ,
560
+ expect ( result . statusCode ) . toBe ( HttpErrorCodes . INTERNAL_SERVER_ERROR ) ;
561
+ const body = JSON . parse ( result . body ) ;
562
+ expect ( body . error ) . toBe ( 'Internal Server Error' ) ;
563
+ expect ( body . message ) . toBe ( 'This error is thrown from the error handler' ) ;
564
+ expect ( body . stack ) . toBeDefined ( ) ;
565
+ expect ( body . details ) . toEqual ( {
566
+ errorName : 'Error' ,
568
567
} ) ;
569
568
} ) ;
570
569
} ) ;
0 commit comments