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

Running tests yields errors #68

Closed
jh3y opened this issue Feb 27, 2019 · 6 comments · Fixed by #787
Closed

Running tests yields errors #68

jh3y opened this issue Feb 27, 2019 · 6 comments · Fixed by #787
Assignees
Labels
blocked bug Something isn't working graphql-hooks graphql-hooks package

Comments

@jh3y
Copy link
Contributor

jh3y commented Feb 27, 2019

Environment

  • graphql-hooks version: 3.1.1
  • react version: 16.8.3
  • Browser: N/A

Description

Running npm run test yields several errors although the tests pass.

Warning: An update to TestHook 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://fb.me/react-wrap-tests-with-act

I believe the errors are printed when running useQuery.test.js and useClientRequest.test.js.

How to reproduce

npm run test

Suggested solution (optional)

  • Potential versioning issue?
@jh3y jh3y changed the title Running tests yields react-testing-library errors Running tests yields errors Feb 27, 2019
@jackdclark
Copy link
Contributor

This was introduced in #32. I've added a comment explaining what the issue is in the test file but we're waiting to see what happens with this react issue facebook/react#14769.

@jackdclark jackdclark added bug Something isn't working graphql-hooks graphql-hooks package blocked labels Mar 5, 2019
@threepointone
Copy link

we just released an alpha with async act() implementation that should solve these issues (assuming you were having trouble with an async test). the link in your comment doesn't work anymore? lemme know if you have issues with the alpha, and I'd be happy to pitch in and help fix it.

@bmullan91
Copy link
Contributor

@threepointone ah the comment link got lost after the lerna move. Here it is: https://github.com/nearform/graphql-hooks/blob/master/packages/graphql-hooks/test/unit/useClientRequest.test.js#L262-L281

Great work on facebook/react#14853 btw - I've just tried 16.9.0-alpha.0 locally and all the big scaryWarning: An update to TestHook inside a test was not wrapped in act(...). logs are gone 🎉

@bmullan91 bmullan91 mentioned this issue Nov 28, 2019
3 tasks
@bmullan91
Copy link
Contributor

Fixed in #412

@nuragic
Copy link
Member

nuragic commented Jan 10, 2022

We still have this console error when running unit tests: Warning: An update to TestComponent inside a test was not wrapped in act(...).

I've also found that in #604 @salmanm talk about these warnings and suggest that the proposed solution would avoid them.

@nuragic nuragic reopened this Jan 10, 2022
@simoneb
Copy link
Member

simoneb commented Jan 10, 2022

Shall we fail the build when those warnings happen? Or we'll keep introducing them

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

Successfully merging a pull request may close this issue.

7 participants