File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
packages/sveltekit/test/server-common Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -91,5 +91,29 @@ describe('handleError', () => {
9191 // Check that the default handler wasn't invoked
9292 expect ( consoleErrorSpy ) . toHaveBeenCalledTimes ( 0 ) ;
9393 } ) ;
94+
95+ it ( 'calls waitUntil if available' , async ( ) => {
96+ const wrappedHandleError = handleErrorWithSentry ( ) ;
97+ const mockError = new Error ( 'test' ) ;
98+ const waitUntilSpy = vi . fn ( ) ;
99+
100+ await wrappedHandleError ( {
101+ error : mockError ,
102+ event : {
103+ ...requestEvent ,
104+ platform : {
105+ context : {
106+ waitUntil : waitUntilSpy ,
107+ } ,
108+ } ,
109+ } ,
110+ status : 500 ,
111+ message : 'Internal Error' ,
112+ } ) ;
113+
114+ expect ( waitUntilSpy ) . toHaveBeenCalledTimes ( 1 ) ;
115+ // flush() returns a promise, this is what we expect here
116+ expect ( waitUntilSpy ) . toHaveBeenCalledWith ( expect . any ( Promise ) ) ;
117+ } ) ;
94118 } ) ;
95119} ) ;
You can’t perform that action at this time.
0 commit comments