Skip to content
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: fix flaky e2e #2158

Merged
merged 9 commits into from
Dec 23, 2024
Merged

test: fix flaky e2e #2158

merged 9 commits into from
Dec 23, 2024

Conversation

brtkx
Copy link
Contributor

@brtkx brtkx commented Dec 20, 2024

No description provided.

Copy link

vercel bot commented Dec 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
arbitrum-token-bridge ✅ Ready (Inspect) Visit Preview Dec 23, 2024 8:56am

@cla-bot cla-bot bot added the cla-signed label Dec 20, 2024
@@ -50,7 +50,7 @@ describe('Approve token for deposit', () => {
* If confirm spending fails, test is still considered to be passing by Cypress
* We add another check to make sure the test fails if needed
*/
cy.wait(10_000)
cy.wait(25_000)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orbit chains may take longer, sometimes the tests fail because they don't have enough time to run

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we only make it 25_000 when it's running for an Orbit chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good to have it for both, I'm only guessing it's for Orbit only as I've observed in the videos. But to be sure I'd leave it for both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, 15 extra seconds doesn't matter because we always wait for withdrawal e2e to finish at the end, they take a bit longer

timeout: 60_000,
interval: 500
})
cy.findTransactionInTransactionHistory(txData)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitUntil doesn't work properly here because it needs to return a result. I've moved timeout to the method itself so we always try for 120_000

.then(parseFloat)
.should(
'be.gt',
cy.findByLabelText(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invoke doesn't follow the retry mechanism, so the default timeout is not respected. With this change we apply the default timeout and fail tests less often.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also add a { timeout: 10_000 } as the second arg of findByLabelText

Copy link
Contributor Author

@brtkx brtkx Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a default timeout of 20_000 for all commands now. Currently we used synpress's default timeout of 4_000 for all commands. This is not enough and caused some flakiness.

With 20_000 we don't really make the tests longer, they will only fail longer if they do.

@@ -103,7 +103,7 @@ describe('Withdraw ERC20 Token', () => {
})

context('should show clickable withdraw button', () => {
cy.findMoveFundsButton().click()
cy.startTransfer({ shouldConfirmInMetamask: false })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startTransfer has wait methods to ensure there are no race conditions. For withdrawals we don't want to confirm in metamask popup because we have our dialogs that pop up before that.

@brtkx brtkx marked this pull request as ready for review December 20, 2024 15:53
@@ -226,7 +226,8 @@ export default defineConfig({
},
baseUrl: 'http://localhost:3000',
specPattern: tests,
supportFile: 'tests/support/index.ts'
supportFile: 'tests/support/index.ts',
defaultCommandTimeout: 20_000
Copy link
Contributor Author

@brtkx brtkx Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default it's set to 4_000. It's not enough given a lot of things are awaited for (e.g. balance changes after transfer etc), so we bump it by a significant amount.

This won't make checks any longer than they are now, only if it fails it will take a bit longer to fail. But it's a good tradeoff to eliminate flakiness.

@spsjvc spsjvc self-requested a review December 23, 2024 10:41
@brtkx brtkx merged commit 7e457c3 into master Dec 23, 2024
75 checks passed
@brtkx brtkx deleted the flaky-e2e branch December 23, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants