testing-library / user-event

🐕 Simulate user events
https://testing-library.com/user-event
MIT License
2.2k stars 249 forks source link

@testing-library/user-event 14.x doesn't work with @testing-library/react 12.5.1 and React <18 #1123

Closed alveshelio closed 1 year ago

alveshelio commented 1 year ago

Reproduction example

https://codesandbox.io/p/sandbox/determined-tesla-82p2up?file=%2Fsrc%2Fcomponents%2FItemList.test.tsx

Prerequisites

  1. npm run test

Expected behavior

await user.click(screen.getByRole('button')) should click the button.

Actual behavior

await user.click(screen.getByRole('button')) throws a thrown: "Exceeded timeout of 5000 ms for a test.

User-event version

14.4.3

Environment

"jest": "^29.5.0", "ts-jest": "^29.1.0",

Additional context

No response

alveshelio commented 1 year ago

This is not an issue with @testing-library/user-event not working with @testing-library/react, it's an issue with fakeTimers https://github.com/testing-library/react-testing-library/issues/1197