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
We have a complex web app and we've been using fireEvent exclusively. Some new features that been implemented, we've decided to use user-event for Jest integration testing.
I can't post the whole test here, but it's basically like this
test('should do something good', async () => {
const { user } = await renderPage();
await screen.findByRole('button', { name: 'Create' });
await user.click(createButton); // using await here causes wrapped into act(...) warning
expect(await screen.findByText('Successfully created')).toBeInTheDocument()
});
If I don't await the user.click then the test passes and there is no "act" warning.
As far as I can tell, since I have an await straight after the user.click, then there's no risk of the click doing something after the test finishes and a valid code.
However, the documentation says you should always await the api calls, so my question here is what are the risks if you don't because they only way that is working for me is if I don't await these calls? baring in mind that I'm using this is an react.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We have a complex web app and we've been using fireEvent exclusively. Some new features that been implemented, we've decided to use
user-event
for Jest integration testing.I can't post the whole test here, but it's basically like this
If I don't
await
theuser.click
then the test passes and there is no "act" warning.As far as I can tell, since I have an
await
straight after theuser.click
, then there's no risk of theclick
doing something after the test finishes and a valid code.However, the documentation says you should always await the api calls, so my question here is what are the risks if you don't because they only way that is working for me is if I don't await these calls? baring in mind that I'm using this is an react.
Beta Was this translation helpful? Give feedback.
All reactions