A
A
Alexey2021-11-11 16:31:00
Software testing
Alexey, 2021-11-11 16:31:00

React testing, I use act, writes that I don't use it, how to fix it?

To render the component I use this entry:

act(() => 
        render(
            <Router history={history}>
                <Route path="/v/:id">
                    <SingleVideo/>
                </Route>
            </Router>
        )
    )


Gives an error message:
When testing, code that causes React state updates should be wrapped into act(...):
      
      act(() => {
        /* fire events that update state */
      });
      /* assert on the output */

Probably a syntax error, tell me how to fix this code?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question