Open
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a retry utility to improve the reliability of flaky Playwright operations by automatically retrying navigation and interaction steps. Key changes include:
- Adding the new retry-helper module with the withRetry function and predefined RetryConditions.
- Refactoring page navigation and settings methods in utils/page-utils.ts to incorporate retry logic.
- Updating test steps in src/support/steps/general.ts to use the retry logic for plugin activation, page visits, and element clicks.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| utils/retry-helper.ts | Added a new retry utility module with withRetry and common retry conditions. |
| utils/page-utils.ts | Updated visitPage and saveSettings methods to use the new retry logic. |
| src/support/steps/general.ts | Refactored test step implementations to include retry logic in flaky operations. |
Comments suppressed due to low confidence (2)
utils/retry-helper.ts:8
- [nitpick] Consider renaming the property 'backoff' to 'useExponentialBackoff' to improve clarity regarding its purpose.
backoff?: boolean; // Exponential backoff
src/support/steps/general.ts:228
- [nitpick] It would be beneficial to add a brief comment explaining the fixed wait time after the click action to clarify its purpose for future maintainability.
await this.page.waitForTimeout(500);
…logic for flaky operations
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
Fixes #237
Implements a new retry logic into page Utils to address flakiness issues with Playwright operations like
page.goto,page.waitForFunction,page.waitForLoadState, andlocator.click.Type of change
Detailed scenario
What was tested
npm run test:smokeHow to test
npm run test:smokeTechnical description
Problem Addressed
E2E tests were experiencing flakiness due to unreliable network conditions, slow page loads, and timing issues with element interactions. Common failures included:
page.goto()locator.click()page.waitForLoadState()Solution
This PR introduces a comprehensive retry mechanism that automatically retries flaky operations with configurable options, improving test reliability without requiring manual intervention.
How to Use
Basic Usage
Documentation
This pull request introduces a retry utility to improve the reliability of Playwright tests and integrates it into various test steps and utility methods. The most important changes include adding the
retry-helper.tsmodule, refactoring test steps to use the retry logic, and updating utility methods for better error handling and retries.Retry Utility Implementation:
utils/retry-helper.ts: Added a new moduleretry-helper.tsthat provides awithRetryfunction for executing operations with retry logic, including configurable options like maximum attempts, delay, exponential backoff, and custom retry conditions. Also introduced common retry conditions such asnetworkErrorsandelementErrors.Integration of Retry Logic in Test Steps:
src/support/steps/general.ts: Refactored several test steps (plugin is activated,I go to {string},I visit {string}, andI click on {string}) to use thewithRetryutility for handling flaky operations. Added retry configurations with appropriate conditions and delays for each step. [1] [2]Updates to Utility Methods:
utils/page-utils.ts: Updated thevisitPageandsaveSettingsmethods to include retry logic using thewithRetryutility. Enhanced error handling for network and element-related issues, ensuring operations are retried as needed. [1] [2]Dependency Updates:
src/support/steps/general.tsandutils/page-utils.ts: ImportedwithRetryandRetryConditionsfrom the newretry-helper.tsmodule to enable retry functionality in test steps and utility methods. [1] [2]New dependencies
None
Risks
None
Mandatory Checklist
Code validation
Code style