-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add tests for ChatPageContent component #54
Add tests for ChatPageContent component #54
Conversation
add MessageBubble unit tests add MessageContent unit tests remove MessageFooter which is not needed anymore Signed-off-by: Yulong Ruan <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/agent-framework #54 +/- ##
============================================================
+ Coverage 27.40% 39.33% +11.93%
============================================================
Files 40 40
Lines 905 905
Branches 223 223
============================================================
+ Hits 248 356 +108
+ Misses 650 541 -109
- Partials 7 8 +1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Yulong Ruan <[email protected]>
|
||
jest.mock('./messages/message_content', () => { | ||
return { MessageContent: () => <div /> }; | ||
}); |
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.
just curious why are child components mocked?
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.
That's a good question! There has been lots of discussions around this. For unit test, I tend to mock child components in RTL which are smart components, for example, the components that:
- Access data via API call
- Have side effects such as read/write local storage
- Access context
- Access global state
By mocking such components, I think it makes the tests concise and less fragile. And ofc, the child component should be covered by its own unit tests.
3d46971
into
opensearch-project:feature/agent-framework
add MessageBubble unit tests
add MessageContent unit tests
remove MessageFooter which is not needed anymore
Description
Describe what this change achieves.
Issues Resolved
List any issues this PR will resolve, e.g. Closes [...].
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.