Testing React components that fetches data using Hooks
That issue is caused by many updates inside Component. I got the same issue, this would solve the issue. await act( async () => mount(<App />));
That issue is caused by many updates inside Component. I got the same issue, this would solve the issue. await act( async () => mount(<App />));
In general, using hooks shouldn’t change testing strategy much. The bigger issue here actually isn’t the hook, but the use of context, which complicates things a bit. There’s a number of ways to make this work, but only approach I’ve found that works with ‘react-test-renderer/shallow’ is to inject a mock hook: import ShallowRenderer from ‘react-test-renderer/shallow’; … Read more