Florian B
Florian B

Reputation: 39

An update to Provider inside a test was not wrapped in act(...) with Jest + React Testing Library

I'm trying to test my React Application with React Testing Library and Jest but I always have the following error.

An update to StoreProvider inside a test was not wrapped in act(...)

I tried many things like put act() function around my test but can't be able to remove the warning and get the correct result.

Here's a simplified project that demonstate the problem: https://codesandbox.io/s/adoring-haslett-6rq34?file=/src/PageContent.test.js

Thanks for your help.

Upvotes: 0

Views: 1650

Answers (1)

Florian B
Florian B

Reputation: 39

Here's a working solution.

https://github.com/testing-library/react-testing-library/issues/641#event-3244842083

I have to waitFor an element

const { findByText } = render(<App />)
expect(await findByText('STATUS = 0')).toBeInTheDocument();

Upvotes: 2

Related Questions