docs(testing): ban nested findBy inside waitFor in CV skill - #132
Merged
Conversation
findBy already polls via waitFor with the same 1s default, so nesting them flakes in CI with a bare timeout and no assertion detail. Co-authored-by: Cursor <cursoragent@cursor.com>
racitores
marked this pull request as ready for review
August 19, 2026 15:50
javiergarciavera
approved these changes
Aug 19, 2026
racitores
enabled auto-merge (squash)
August 19, 2026 15:52
10 tasks
pull Bot
pushed a commit
to Reality2byte/metamask-mobile
that referenced
this pull request
Aug 20, 2026
MetaMask#35032) ## **Description** <!-- mms-check: type=text required=true --> Fixes two flaky component-view waits that surfaced as CI failures. Both are the same class of defect: the assertion does not actually wait for the value being asserted. **1. `WatchlistFullScreenView.view.test.tsx` — nested waiters** The test `loads and displays all token fields for each editable row (newest first)` failed with `Timed out in waitFor.` and no assertion detail. It nested `findAllByTestId` inside `waitFor`. `findBy*` already polls via `waitFor` (default 1000 ms), so both waiters share that budget and the outer one expires before the inner query can surface a real assertion error. Locally the nock + React Query path resolves in time; on a loaded CI runner it does not. It now uses a single `waitFor` with a synchronous `getAllByTestId` callback and an explicit `{ timeout: 5000 }`, matching the search test in the same file. A failure now reports the actual row count instead of a bare timeout. **2. `ActivityDetails.view.test.tsx` — awaiting the container, not the content** The Solana total row asserted a converted fiat amount (`$4.00` / `$8.00`) synchronously. The row renders before the multichain conversion rate resolves, so CI intermittently read `Total amount$0.00`. This blocked an earlier run of this PR. Both assertions are now wrapped in `waitFor` so they poll until the rate settles. The awaited condition is the fiat text itself rather than the row that contains it. The nested-waiter antipattern was also present in the canonical component-view testing guidance, fixed in [MetaMask/skills#132](MetaMask/skills#132). ## **Changelog** <!-- mms-check: type=changelog required=true blocking=true --> CHANGELOG entry: null ## **Related issues** <!-- mms-check: type=issue-link required=true --> Refs: failing CI runs [93933344701](https://github.com/MetaMask/metamask-mobile/actions/runs/31537555318/job/93933344701) (watchlist) and [96133976774](https://github.com/MetaMask/metamask-mobile/actions/runs/32272692323/job/96133976774) (activity details) ## **Manual testing steps** <!-- mms-check: type=manual-testing required=true --> N/A — component view tests only, no runtime code touched. Verified locally on the merged branch, both platforms: ``` TEST_OS=ios yarn jest -c jest.config.view.js app/components/UI/Assets/watchlist/Views/WatchlistFullScreenView/WatchlistFullScreenView.view.test.tsx TEST_OS=ios yarn jest -c jest.config.view.js app/components/Views/ActivityDetails/ActivityDetails.view.test.tsx TEST_OS=android yarn jest -c jest.config.view.js app/components/Views/ActivityDetails/ActivityDetails.view.test.tsx ``` All green (4 and 19 tests respectively). ## **Screenshots/Recordings** <!-- mms-check: type=screenshot required=true --> ### **Before** N/A — no user-facing change. ### **After** N/A — no user-facing change. ## **Pre-merge author checklist** <!-- mms-check: type=checklist required=true --> - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) Not applicable — test-only change, no runtime code touched. - [ ] I've tested on Android - [ ] I've tested with a power user scenario - [ ] I've instrumented key operations with Sentry traces for production performance metrics ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or 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
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
Component view tests that wrap
findBy*inwaitFordouble-poll with the same 1s default timeout. Under CI load the outer waiter expires first and the log is onlyTimed out in waitFor.with no assertion detail (seen onWatchlistFullScreenView.view.test.tsx).The mobile-testing CV skill still taught that nested shape in the data-completeness and nock examples. This change:
find*insidewaitForawait findBy*(orwaitFor+getBy*+{ timeout })Type of Change
Skill Details (if adding a new skill)
Provider Name:
Skill Name:
Brief Description:
Checklist
Testing
N/A — documentation-only. Verified remaining
waitFor(async () => findBy*)occurrences in the CV skill are the new ❌ examples.Additional Context
Canonical skill:
testing/mobile-testing→references/component-view.md(andcomponent-view/writing-tests.md,reference.md,navigation-mocking.md).After merge, run
yarn skillsin metamask-mobile so local agents pick this up. The in-repo copy atdocs/testing/component-view-tests.mdis separate and still has the old example until that file is synced.Made with Cursor