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

Fix React warnings in useDocuments tests #299

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

HerbCaudill
Copy link
Collaborator

When running tests we get several copies of this warning:

Warning: An update to TestComponent inside a test was not wrapped in act(...).

When testing, code that causes React state updates should be wrapped into act(...):

act(() => {
  /* fire events that update state */
});
/* assert on the output */

This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
    at TestComponent (automerge-repo/node_modules/.pnpm/@testing-library+react@14.1.2_react-dom@18.2.0_react@18.2.0/node_modules/@testing-library/react/dist/pure.js:278:5)
    at automerge-repo/packages/automerge-repo-react-hooks/test/useDocuments.test.tsx:90:37

This PR follows the warning's advice and wraps the stuff that causes state updates in act(...).

@HerbCaudill HerbCaudill requested a review from pvh February 29, 2024 11:31
@pvh
Copy link
Member

pvh commented Mar 1, 2024

I mean, I don't see why but sure.

@pvh pvh merged commit bf4c02c into main Mar 1, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants