Given this component:
const OnMount = ({ onMount }) => {
useEffect(() => {
onMount();
}, []);
return <span>Hey</span>;
};
This test passes (the component is mounted once only):
const onMount = jest.fn()
const { rerender } = render(
<OnMount onMount={onMount} />,
{ wrapper: wrap(withSomething()) }
)
rerender()
expect(onMount)toHaveBeenCalledTimes(1)
But if you instead do wrap(withSomething(), withASecondThing()) then the component is mounted twice and the assertion fails. Even if the wrapper components are trivial.
The bug is probably somewhere in wrap() or composeComponents() (which it calls).
Given this component:
This test passes (the component is mounted once only):
But if you instead do
wrap(withSomething(), withASecondThing())then the component is mounted twice and the assertion fails. Even if the wrapper components are trivial.The bug is probably somewhere in
wrap()orcomposeComponents()(which it calls).