The following post somewhat describes my issueHow to simulate android back button in react-native test but in my case I'm not actually using the BackHandler
, but the onRequestClose prop on a modal.
So is there any way to actually trigger a simulated back press, as the onRequestClose
prop is triggered from java code?
Hack solution:
const modal = screen.getByA11yHint('some cool modal');// wait for the modal to loadawait within(modal).findByText('Async data');act(() => modal.props.onRequestClose());expect(() => screen.getByA11yHint('some cool modal'),).to.throw();