[NoQA] Add unit testing guide and example tests#52867
[NoQA] Add unit testing guide and example tests#52867mountiny merged 4 commits intoExpensify:mainfrom
Conversation
|
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@mountiny would you like me to review the testing example or all or you can handle this PR? |
tgolen
left a comment
There was a problem hiding this comment.
I love this. The examples you added are great!
tests/ui/README.md
Outdated
| ### Don’ts | ||
|
|
||
| - Don’t test implementation details (e.g., state variables or internal method calls). | ||
| - Don’t ignore warnings: Fix `act()` or other common warnings to ensure reliability. |
There was a problem hiding this comment.
Could you please add more guidance for act()? It has always confused me
There was a problem hiding this comment.
Added a short explanation and clarified when manual usage is needed
tests/ui/README.md
Outdated
| ### Do’s | ||
|
|
||
| - Write tests that reflect actual user behavior (e.g., clicking buttons, filling forms). | ||
| - Mock external dependencies like network calls or Onyx data. |
There was a problem hiding this comment.
| - Mock external dependencies like network calls or Onyx data. | |
| - Mock external dependencies like network calls or Onyx data. If the amount of onyx data is large, place it in an external JSON file with the same name as the test file and import the data. |
tests/ui/README.md
Outdated
| - Mock external dependencies like network calls or Onyx data. | ||
| - Use `findBy` and `waitFor` to handle asynchronous updates in the UI. | ||
| - Follow naming conventions for test IDs (`testID="component-name-action"`). | ||
| - Test for accessibility attributes like `accessibilityLabel`, `accessibilityHint`, etc., to improve test coverage for screen readers. |
There was a problem hiding this comment.
I think some more explanation could be added here. What would those attributes be tested for and how should they be tested?
There was a problem hiding this comment.
Added more details and example.
f130ca3 to
d90f9cb
Compare
tgolen
left a comment
There was a problem hiding this comment.
Looks great! I just spotted these two small fixes.
d90f9cb to
c666ade
Compare
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
mountiny
left a comment
There was a problem hiding this comment.
All our comments addressed so I will not hold this back and merge. @puneetlath feel free to review even after this is merged
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.67-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.67-9 🚀
|
Explanation of Change
This PR adds a UI testing Guide with best practices and basic example tests for components
Fixed Issues
$ #52771
PROPOSAL:
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop