@@ -38,6 +38,7 @@ describe('handleError', () => {
38
38
it ( 'invokes the default handler if no handleError func is provided' , async ( ) => {
39
39
const wrappedHandleError = handleErrorWithSentry ( ) ;
40
40
const mockError = new Error ( 'test' ) ;
41
+ // @ts -expect-error - purposefully omitting status and message to cover SvelteKit 1.x compatibility
41
42
const returnVal = await wrappedHandleError ( { error : mockError , event : navigationEvent } ) ;
42
43
43
44
expect ( returnVal ) . not . toBeDefined ( ) ;
@@ -50,6 +51,7 @@ describe('handleError', () => {
50
51
it ( 'invokes the user-provided error handler' , async ( ) => {
51
52
const wrappedHandleError = handleErrorWithSentry ( handleError ) ;
52
53
const mockError = new Error ( 'test' ) ;
54
+ // @ts -expect-error - purposefully omitting status and message to cover SvelteKit 1.x compatibility
53
55
const returnVal = ( await wrappedHandleError ( { error : mockError , event : navigationEvent } ) ) as any ;
54
56
55
57
expect ( returnVal . message ) . toEqual ( 'Whoops!' ) ;
@@ -59,4 +61,19 @@ describe('handleError', () => {
59
61
expect ( consoleErrorSpy ) . toHaveBeenCalledTimes ( 0 ) ;
60
62
} ) ;
61
63
} ) ;
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
+ } ) ;
62
79
} ) ;
0 commit comments