Skip to content

Commit 9d14506

Browse files
committed
add test
1 parent 7550f05 commit 9d14506

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/sveltekit/test/server-common/handleError.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)