Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Simulate hardware back press in react-native test

$
0
0

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();

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>