We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is your feature request related to a problem? Please describe. When using jest fake timers You have to turn off delay in user setup. I haven't found this description in the doxs, have to use: https://onestepcode.com/testing-library-user-event-with-fake-timers/ blog post.
Please add this for future generations, thanks :)
describe('test', () => { beforeEach(() => { jest.useFakeTimers(); jest.setSystemTime(new Date('2022-01-01').getTime()); }); afterEach(() => { jest.useRealTimers(); }); test('When user clicks something is going on', async () => { const { getAllByRole } = render(<ComponentWithTimersDependency />); const user= userEvent.setup(); const buttons = getAllByRole('button'); await user.click(buttons[0]); // this line will run till timeout }); });
Describe the solution you'd like solution:
test('When user clicks something is going on', async () => { const { getAllByRole } = render(<ComponentWithTimersDependency />); const userCompatibleWithFakeTimer = userEvent.setup({ delay: null }); const buttons = getAllByRole('button'); await userCompatibleWithFakeTimer.click(buttons[0]); // all good! });
The text was updated successfully, but these errors were encountered:
Since v14.1 you can use the advanceTimers option.
v14.1
advanceTimers
Sorry, something went wrong.
docs: clarify fake timer usage with user-event (#1391)
b2be4bb
Closes #1180
Successfully merging a pull request may close this issue.
Is your feature request related to a problem? Please describe.
When using jest fake timers You have to turn off delay in user setup. I haven't found this description in the doxs, have to use: https://onestepcode.com/testing-library-user-event-with-fake-timers/ blog post.
Please add this for future generations, thanks :)
Describe the solution you'd like
solution:
The text was updated successfully, but these errors were encountered: