@@ -38,6 +38,7 @@ describe('handleError', () => {
3838 it ( 'invokes the default handler if no handleError func is provided' , async ( ) => {
3939 const wrappedHandleError = handleErrorWithSentry ( ) ;
4040 const mockError = new Error ( 'test' ) ;
41+ // @ts -expect-error - purposefully omitting status and message to cover SvelteKit 1.x compatibility
4142 const returnVal = await wrappedHandleError ( { error : mockError , event : navigationEvent } ) ;
4243
4344 expect ( returnVal ) . not . toBeDefined ( ) ;
@@ -50,6 +51,7 @@ describe('handleError', () => {
5051 it ( 'invokes the user-provided error handler' , async ( ) => {
5152 const wrappedHandleError = handleErrorWithSentry ( handleError ) ;
5253 const mockError = new Error ( 'test' ) ;
54+ // @ts -expect-error - purposefully omitting status and message to cover SvelteKit 1.x compatibility
5355 const returnVal = ( await wrappedHandleError ( { error : mockError , event : navigationEvent } ) ) as any ;
5456
5557 expect ( returnVal . message ) . toEqual ( 'Whoops!' ) ;
@@ -59,4 +61,19 @@ describe('handleError', () => {
5961 expect ( consoleErrorSpy ) . toHaveBeenCalledTimes ( 0 ) ;
6062 } ) ;
6163 } ) ;
64+
65+ it ( 'doesn\'t capture "Not Found" errors' , async ( ) => {
66+ const wrappedHandleError = handleErrorWithSentry ( handleError ) ;
67+ const returnVal = ( await wrappedHandleError ( {
68+ error : new Error ( '404 Not Found' ) ,
69+ event : navigationEvent ,
70+ status : 404 ,
71+ message : 'Not Found' ,
72+ } ) ) as any ;
73+
74+ expect ( returnVal . message ) . toEqual ( 'Whoops!' ) ;
75+ expect ( mockCaptureException ) . not . toHaveBeenCalled ( ) ;
76+ // Check that the default handler wasn't invoked
77+ expect ( consoleErrorSpy ) . toHaveBeenCalledTimes ( 0 ) ;
78+ } ) ;
6279} ) ;
0 commit comments