Unit testing React click outside component using Jest and react testing library April 7, 2024 by Tarik as @Giorgio mentioned: fireEvent.click(document) //or userEvent.click(document.body);