Skip to content

Commit d1b5886

Browse files
chore: workaround for User Event press race condition in tests (#1736)
1 parent 9efe13e commit d1b5886

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/user-event/press/__tests__/press.real-timers.test.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,12 @@ describe('userEvent.press with real timers', () => {
197197
);
198198
await user.press(screen.getByTestId('pressable'));
199199

200-
expect(getEventsNames(events)).toEqual(['pressIn', 'pressOut', 'press']);
200+
const eventsNames = getEventsNames(events).join(', ');
201+
// Typical event order is pressIn, pressOut, press
202+
// But sometimes due to a race condition, the order is pressIn, press, pressOut.
203+
expect(
204+
eventsNames === 'pressIn, pressOut, press' || eventsNames === 'pressIn, press, pressOut',
205+
).toBe(true);
201206
});
202207

203208
test('crawls up in the tree to find an element that responds to touch events', async () => {

0 commit comments

Comments
 (0)