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
Attempting to use fake timers and assert those dates and times after using waitFor
What happened:
The system time was reset to the current time after waitFor.
Reproduction:
import{render,screen,waitFor}from'@testing-library/react';beforeEach(()=>{jest.useFakeTimers('modern');jest.setSystemTime(newDate("2023-02-18"));})afterEach(()=>{jest.runOnlyPendingTimers()jest.useRealTimers()})test('test the fake timer',async()=>{render((<p>text</p>));awaitwaitFor(()=>screen.getByText('text'))expect(newDate().getFullYear()).toEqual(2023)});
When using waitFor it appears that the system time that was set using Jest's fake timers was reset to the current time. If you remove the waitFor the test passes as expected.
The text was updated successfully, but these errors were encountered:
@testing-library/dom
version:@testing-library/[email protected]
[email protected]
[email protected]
What you did:
Attempting to use fake timers and assert those dates and times after using
waitFor
What happened:
The system time was reset to the current time after
waitFor
.Reproduction:
Problem description:
Test results:
When using
waitFor
it appears that the system time that was set using Jest's fake timers was reset to the current time. If you remove thewaitFor
the test passes as expected.The text was updated successfully, but these errors were encountered: