Skip to content

Commit a4ffb19

Browse files
authored
test(react-router): Unflake flushIfServerless test (#17610)
This test flaked before because we used real timers and apparently `setTimeout(_, 10)` sometimes caused an absolute delay <10 ms. Let's use fake timers instead which should(?) ensure that this works correctly in the test fixture. closes #17611
1 parent e083772 commit a4ffb19

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/react-router/test/server/createSentryHandleError.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ describe('createSentryHandleError', () => {
156156
});
157157

158158
describe('flushIfServerless behavior', () => {
159-
it('should wait for flushIfServerless to complete', async () => {
159+
it('waits for flushIfServerless to complete', async () => {
160+
vi.useFakeTimers();
160161
const handleError = createSentryHandleError({});
161162

162163
let resolveFlush: () => void;
@@ -172,7 +173,8 @@ describe('createSentryHandleError', () => {
172173

173174
const handleErrorPromise = handleError(mockError, mockArgs);
174175

175-
setTimeout(() => resolveFlush(), 10);
176+
vi.advanceTimersByTime(10);
177+
resolveFlush!();
176178

177179
await handleErrorPromise;
178180
const endTime = Date.now();

0 commit comments

Comments
 (0)