@@ -35,18 +35,39 @@ describe('handleError', () => {
3535 // ...
3636 } as RequestEvent ;
3737
38+ // @ts -expect-error - leaving this input as is for SvelteKit 1.x compatibility (status and message are missing)
3839 const returnVal = await wrappedHandleError ( { error : mockError , event : mockEvent } ) ;
3940
4041 expect ( returnVal ) . not . toBeDefined ( ) ;
4142 expect ( mockCaptureException ) . toHaveBeenCalledTimes ( 0 ) ;
4243 expect ( consoleErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
4344 } ) ;
4445
46+ it ( 'doesn\'t capture "Not found" errors for incorrect navigations' , async ( ) => {
47+ const wrappedHandleError = handleErrorWithSentry ( ) ;
48+
49+ const returnVal = await wrappedHandleError ( {
50+ error : new Error ( '404 /asdf/123' ) ,
51+ event : requestEvent ,
52+ status : 404 ,
53+ message : 'Not Found' ,
54+ } ) ;
55+
56+ expect ( returnVal ) . not . toBeDefined ( ) ;
57+ expect ( mockCaptureException ) . toHaveBeenCalledTimes ( 0 ) ;
58+ expect ( consoleErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
59+ } ) ;
60+
4561 describe ( 'calls captureException' , ( ) => {
4662 it ( 'invokes the default handler if no handleError func is provided' , async ( ) => {
4763 const wrappedHandleError = handleErrorWithSentry ( ) ;
4864 const mockError = new Error ( 'test' ) ;
49- const returnVal = await wrappedHandleError ( { error : mockError , event : requestEvent } ) ;
65+ const returnVal = await wrappedHandleError ( {
66+ error : mockError ,
67+ event : requestEvent ,
68+ status : 500 ,
69+ message : 'Internal Error' ,
70+ } ) ;
5071
5172 expect ( returnVal ) . not . toBeDefined ( ) ;
5273 expect ( mockCaptureException ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -58,7 +79,12 @@ describe('handleError', () => {
5879 it ( 'invokes the user-provided error handler' , async ( ) => {
5980 const wrappedHandleError = handleErrorWithSentry ( handleError ) ;
6081 const mockError = new Error ( 'test' ) ;
61- const returnVal = ( await wrappedHandleError ( { error : mockError , event : requestEvent } ) ) as any ;
82+ const returnVal = ( await wrappedHandleError ( {
83+ error : mockError ,
84+ event : requestEvent ,
85+ status : 500 ,
86+ message : 'Internal Error' ,
87+ } ) ) as any ;
6288
6389 expect ( returnVal . message ) . toEqual ( 'Whoops!' ) ;
6490 expect ( mockCaptureException ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments