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

RTL error: not wrapped in act() #65

Open
lorensr opened this issue Dec 2, 2020 · 0 comments
Open

RTL error: not wrapped in act() #65

lorensr opened this issue Dec 2, 2020 · 0 comments
Labels

Comments

@lorensr
Copy link
Member

lorensr commented Dec 2, 2020

How to fix this?

git checkout 28
npm test

src/components/App.test.js

import React from 'react'
import App from './App'

it('renders without crashing', () => {
  mockedRender(<App />)
})

has a number of errors like this:

  console.error node_modules/react-dom/cjs/react-dom.development.js:88
    Warning: An update to _default 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
        in _default (at App.js:61)
        in header (at App.js:55)
        in div (at App.js:54)
        in _default (at App.test.js:5)
        in ApolloProvider
        in Unknown (at setupTests.js:47)
        in Router (at setupTests.js:36)
        in RouterWrapper (at setupTests.js:46)
        in MockedWrapper
@lorensr lorensr added the bug label Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant