From 9c3835e0a50ae46d92d2f55cfc844d0d4bc005f0 Mon Sep 17 00:00:00 2001 From: chloeYue <105063779+chloeYue@users.noreply.github.com> Date: Wed, 13 Mar 2024 12:24:41 +0100 Subject: [PATCH] test: fix flaky test in account-token-list.spec.js (#23450) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Reason of flakiness is race condition: we assert value as soon as we found the element, the real value has not been rendered ## **Related issues** Fixes: #23451 ## **Manual testing steps** Run test multiple times with `yarn test:e2e:single --browser=chrome test/e2e/tests/settings/account-token-list.spec.js` ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [x] I've included screenshots/recordings if applicable - [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-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --- test/e2e/tests/settings/account-token-list.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/tests/settings/account-token-list.spec.js b/test/e2e/tests/settings/account-token-list.spec.js index 353d96753280..e681168cbba9 100644 --- a/test/e2e/tests/settings/account-token-list.spec.js +++ b/test/e2e/tests/settings/account-token-list.spec.js @@ -23,6 +23,7 @@ describe('Settings', function () { const tokenListAmount = await driver.findElement( '[data-testid="multichain-token-list-item-value"]', ); + await driver.waitForNonEmptyElement(tokenListAmount); assert.equal(await tokenListAmount.getText(), tokenValue); await driver.clickElement('[data-testid="account-menu-icon"]');