Skip to content
New issue

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

Remove redundant act calls in unit tests once a clear RHF workaround or fix exists #67

Open
brandonlenz opened this issue May 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@brandonlenz
Copy link
Contributor

brandonlenz commented May 4, 2023

Describe the bug

As noted in this discussion, RHF causes extra re-renders which are not captured in the implicit User Event act. In order to avoid large amounts of console output during tests, an extra act wrapper is required:

To Reproduce

Steps to reproduce the behavior:

  1. On any unit test involving user events and form updates (e.g. YesNoQuestion.test.tsx)
  2. Update the unit tests to simply await user.doSomething
  3. Run the tests
  4. See the console warnings

Expected behavior

User events should not need a wrapping act block.
Even waiting for a checked element to be checked before proceeding is not enough.

Code Snippet

Current workaround:

await act(() => user.click(submitButton))

or

await act(() => user.click(yesAnswer))

Correct syntax

await user.click(submitButton)

or

await user.click(yesAnswer)
@brandonlenz brandonlenz added the bug Something isn't working label May 4, 2023
@brandonlenz
Copy link
Contributor Author

Moved to 'blocked' status as I don't think there's currently a better workaround for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant