feat: add advanceTimers option
What: adding a new advanceTimers configuration option to resolve #1197
Possibly also #1393 and #1187, but maintainers are smarter than me about this, whether it also covers those.
Why: as this is currently not configurable, users have to use various workarounds to be able to use this library with vitest and fake timers, e.g.mock jest globals when they are not using jest
How:
- Added a new configuration option,
advanceTimers, with the same name and signature thatuser-eventalready uses: https://github.com/testing-library/user-event/blob/main/src/options.ts#L127. Using the same name and signature should ensure best ecosystem compatibility. - Moved existing jest fake timers check and timers advancing to config and defined it as the default config value. This ensures existing code continues working as expected.
Checklist:
- [ ] Documentation added to the docs site (can do, if needed, once this is approved in principle)
- [x] Tests (can improve, if provided a bit of guidance)
- [x] TypeScript definitions updated
- [x] Ready to be merged
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 9099fe3f2d5e9a2d6ebe74167beb7251f4bef6a1:
| Sandbox | Source |
|---|---|
| react-testing-library-examples | Configuration |
I don't believe the experimental react version test failures are due to these changes, as they also fail on main if I install experimental react & react-dom locally. But let me know if there's something I could do.