You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
krutoo
changed the title
click not working when injectGlobals: false and fake timers enabled
.click() not working when injectGlobals: false and fake timers enabled
Oct 18, 2023
I'm also seeing this happening with Vitest's vi.useFakeTimers(). I insert vi.useFakeTimers() globally as part of my setupFiles as I have a lot of date/time related tests, so the tests that are using userEvent.setup(), if I put vi.useRealTimers() at the start of the unit test, it allows them to run properly again.
I'm also seeing this happening with Vitest's vi.useFakeTimers(). I insert vi.useFakeTimers() globally as part of my setupFiles as I have a lot of date/time related tests, so the tests that are using userEvent.setup(), if I put vi.useRealTimers() at the start of the unit test, it allows them to run properly again.
Update: I'm not doing vi.useFakeTimers() globally anymore and I'm still seeing this issue when I use vi.useFakerTimers() in a test that I use userEvent.setup() in.
Reproduction example
https://github.com/krutoo/testing-library-user-event-with-fake-timers
Prerequisites
Expected behavior
Tests should be done
Actual behavior
Test fails by timeout 5000ms
User-event version
14.5.1
Environment
Testing Library framework:
@testing-library/react@12.1.3
JS framework:
react@18.2.0
Test environment:
jest@29.7.0
DOM implementation:
jest-environment-jsdom@29.7.0
Additional context
In jest config I use
injectGlobals: false
and may be its the reasonI also use
userEvent.setup({ advanceTimers: jest.advanceTimersByTime })
and its not solves issue.The text was updated successfully, but these errors were encountered: