react-native-actions-sheet
react-native-actions-sheet copied to clipboard
How can I test the visibility of actionSheet/content?
I'm using @testing-library/react-native to test my app and I noticed that the content of the action sheet is present in the component tree even when it is closed.
Is there a way of testing this?
I'm using
@testing-library/react-nativeto test my app and I noticed that the content of the action sheet is present in the component tree even when it is closed.Is there a way of testing this?
That's normal. Modal works like that. If you don't want it to be in the component tree, you can hide it using state. I think there is a testID prop you can use to give test ID to ActionSheet to test it.
{visible && <ActionSheet>
//....
</ActionSheet>}
Yes, I tried to do that, but I had some problems because the reference is destroyed. I tried something using useEffect / useLayoutEffect and onClose prop, but I started to have some problems with the animation
Yes, I tried to do that, but I had some problems because the reference is destroyed. I tried something using useEffect / useLayoutEffect and onClose prop, but I started to have some problems with the animation
Show me how you are doing it. You need to set state then call show after 50 to 100ms using setTimeout.
v0.8.0 gives several test ids to address this in e2e tests.