Open krutoo opened 1 year ago
Can anyone confirm or deny?
Can reproduce
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 insertvi.useFakeTimers()
globally as part of mysetupFiles
as I have a lot of date/time related tests, so the tests that are usinguserEvent.setup()
, if I putvi.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.