-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not render mocked Modal when visible=false #39157
Conversation
Base commit: 3c87455 |
The failure in test_e2e_android check does not seem to be related to this PR. |
8e1332e
to
07f4ed3
Compare
@@ -13,7 +13,7 @@ exports[`<Modal /> should render as <RCTModalHostView> when not mocked 1`] = ` | |||
<RCTModalHostView | |||
animationType="none" | |||
hardwareAccelerated={false} | |||
identifier={4} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What caused this to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I happens due to Modal
keeping auto-incrementing identifier for each composite Modal
instance. Since tests are not isolated, the removal of rendering of Modal
when visible={false}
in previous test reduced the count by 1.
@lunaleaps has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by @mdjastrzebski in 468a136. When will my fix make it into a release? | Upcoming Releases |
@lunaleaps merged this pull request in 468a136. |
Summary:
Note: this PR is related only to testing mocks provided by RN, and does not affect runtime code.
When building new Jest matchers for React Native Testing Library (callstack/react-native-testing-library#1468) I've noticed that when rendering React Native in Jest using React Test Renderer the mocked
Modal
component renders hostModal
element whenvisible={false}
.This seems to be incorrect as only visible modal should render any host elements. Not visible one should not render any host element even empty ones. Current mock implementation also contradicts the behaviour of non-mocked
Modal
which does not renderRCTModalHostView
in such case.Changelog:
[General] [Fixed] - Do not render mocked when
visible=false
Test Plan:
I've added test showing that non-mocked Modal renders to
null
and modifies the existing tests so that mocked Modal also renders tonull.