-
Notifications
You must be signed in to change notification settings - Fork 920
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
[Test] Wrap FunComponent in unit test with IntlProvider #654
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the FunctionComponent unit tests, we see many console errors: `Could not find required intl object. <IntlProvider> needs to exist in the component ancestry. ` This is because for some unit tests, we mount the FunctionComponent (with Enzyme's mount()) , which access to the react-intl context by FormattedMessage without their <IntlProvider /> parent wrapper. This PR solves 7 out of 8 unit tests with this issue by wrapping the <IntlProvider /> either through original enzyme_helper functions or a simple wrapper wrapWithIntl. Partically Resolved: opensearch-project#593 Signed-off-by: Anan Zhuang <[email protected]>
✅ DCO Check Passed 4af7777 |
kavilla
approved these changes
Jul 22, 2021
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.
LGTM
tmarkley
approved these changes
Jul 22, 2021
ananzh
added a commit
to ananzh/OpenSearch-Dashboards
that referenced
this pull request
Jul 23, 2021
In the FunctionComponent unit tests, we see many console errors: `Could not find required intl object. <IntlProvider> needs to exist in the component ancestry. ` This is because for some unit tests, we mount the FunctionComponent (with Enzyme's mount()) , which access to the react-intl context by FormattedMessage without their <IntlProvider /> parent wrapper. This PR solves 7 out of 8 unit tests with this issue by wrapping the <IntlProvider /> either through original enzyme_helper functions or a simple wrapper wrapWithIntl. Partically Resolved: opensearch-project#593 Backport PR: opensearch-project#654 Signed-off-by: Anan Zhuang <[email protected]>
ananzh
added a commit
to ananzh/OpenSearch-Dashboards
that referenced
this pull request
Jul 23, 2021
In the FunctionComponent unit tests, we see many console errors: `Could not find required intl object. <IntlProvider> needs to exist in the component ancestry. ` This is because for some unit tests, we mount the FunctionComponent (with Enzyme's mount()) , which access to the react-intl context by FormattedMessage without their <IntlProvider /> parent wrapper. This PR solves 7 out of 8 unit tests with this issue by wrapping the <IntlProvider /> either through original enzyme_helper functions or a simple wrapper wrapWithIntl. Partically Resolved: opensearch-project#593 Backport PR: opensearch-project#654 Signed-off-by: Anan Zhuang <[email protected]>
5 tasks
ananzh
added a commit
that referenced
this pull request
Jul 23, 2021
In the FunctionComponent unit tests, we see many console errors: `Could not find required intl object. <IntlProvider> needs to exist in the component ancestry. ` This is because for some unit tests, we mount the FunctionComponent (with Enzyme's mount()) , which access to the react-intl context by FormattedMessage without their <IntlProvider /> parent wrapper. This PR solves 7 out of 8 unit tests with this issue by wrapping the <IntlProvider /> either through original enzyme_helper functions or a simple wrapper wrapWithIntl. Partically Resolved: #593 Backport PR: #654 Signed-off-by: Anan Zhuang <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In the FunctionComponent unit tests, we see many console errors:
This is because for some unit tests, we mount the FunctionComponent(with Enzyme's mount()) , which access to the react-intl context by FormattedMessage without their parent wrapper.
This PR solves 7 out of 8 unit tests with this issue by wrapping the . The enzyme_helper contains functions with injected intl object and 4 unit tests can eliminate console error by switching mount to mountWithIntl and render to renderWithIntl. For the other 3 unit tests, the argument type wrappingComponent is not assignable to parameter of type context. This PR wraps these components with simple IntlProvider.
Partically Resolved:
#593
Test result:
src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx
/src/plugins/index_pattern_management/public/components/field_editor/components/scripting_call_outs/warning_call_out.test.tsx
src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/header/header.test.tsx
src/core/public/core_app/status/components/server_status.test.tsx
src/core/public/application/ui/app_container.test.tsx
src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx
Check List