Guides
Testing
Reset the global modal stack between tests and exercise async modal flows.
hideAll is useful as suite cleanup because it does nothing when the portal is not mounted:
import { magicModal } from "react-native-magic-modal";
beforeEach(() => {
magicModal.hideAll();
});For integration tests, render the same roots the application uses:
render(
<GestureHandlerRootView>
<ScreenUnderTest />
<MagicModalPortal />
</GestureHandlerRootView>,
);Then trigger the action, query modal content normally, and press the control that calls
useMagicModal().hide.
Prefer interacting with rendered content over calling magicModal.hide
directly. That covers the component's return data as well as the modal
plumbing.