Skip to content

RTL error: not wrapped in act() #65

Open
@lorensr

Description

@lorensr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions