@@ -19,27 +19,20 @@ describe("Error Handler Middleware", () => {
1919 } ) ;
2020
2121 app . use ( errorHandler ( ) ) ;
22- app . use ( "*" , ( req , res ) => res . status ( StatusCodes . NOT_FOUND ) . send ( "Not Found" ) ) ;
2322 } ) ;
2423
25- describe ( "Handling unknown routes" , ( ) => {
26- it ( "returns 404 for unknown routes" , async ( ) => {
27- const response = await request ( app ) . get ( "/this-route-does-not-exist" ) ;
28- expect ( response . status ) . toBe ( StatusCodes . NOT_FOUND ) ;
29- } ) ;
24+ it ( "returns 404 for unknown routes" , async ( ) => {
25+ const response = await request ( app ) . get ( "/this-route-does-not-exist" ) ;
26+ expect ( response . status ) . toBe ( StatusCodes . NOT_FOUND ) ;
3027 } ) ;
3128
32- describe ( "Handling thrown errors" , ( ) => {
33- it ( "handles thrown errors with a 500 status code" , async ( ) => {
34- const response = await request ( app ) . get ( "/error" ) ;
35- expect ( response . status ) . toBe ( StatusCodes . INTERNAL_SERVER_ERROR ) ;
36- } ) ;
29+ it ( "handles thrown errors with a 500 status code" , async ( ) => {
30+ const response = await request ( app ) . get ( "/error" ) ;
31+ expect ( response . status ) . toBe ( StatusCodes . INTERNAL_SERVER_ERROR ) ;
3732 } ) ;
3833
39- describe ( "Handling errors passed to next()" , ( ) => {
40- it ( "handles errors passed to next() with a 500 status code" , async ( ) => {
41- const response = await request ( app ) . get ( "/next-error" ) ;
42- expect ( response . status ) . toBe ( StatusCodes . INTERNAL_SERVER_ERROR ) ;
43- } ) ;
34+ it ( "handles errors passed to next() with a 500 status code" , async ( ) => {
35+ const response = await request ( app ) . get ( "/next-error" ) ;
36+ expect ( response . status ) . toBe ( StatusCodes . INTERNAL_SERVER_ERROR ) ;
4437 } ) ;
4538} ) ;
0 commit comments