Skip to content

Allow custom advanceTimers implementation and update tick to microtask based approach - #231

Open
OiNutter wants to merge 3 commits into
guidepup:mainfrom
OiNutter:main
Open

Allow custom advanceTimers implementation and update tick to microtask based approach#231
OiNutter wants to merge 3 commits into
guidepup:mainfrom
OiNutter:main

Conversation

@OiNutter

@OiNutter OiNutter commented Sep 7, 2026

Copy link
Copy Markdown

Issue

Fixes #215.

Details

As discussed in original issue allow providing custom advanceTimers implementation to virtual.start() which can then be provided to the internal userEvent usage. To allow this the userEvent usages have been updated to use a shared session created via userEvent.setup. This will also ensure the defaultUserEventOptions are actually applied as expected as v14 of @testing-library/user-event doesn't support passing the options as a second parameter.

Additionally updated the tick helper to use Promise.resolve rather than a setTimeout approach to reduce impact of using fake timers.

Verified existing tests pass and added new tests to ensure custom advanceTimers is called

CheckList

  • Has been tested (where required).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using userEvent when we have fake timers enabled causes act issues.

1 participant