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

Replace Hardcoded cy.wait() with cy.intercept in the cypress files #8925

Open
1 task
nihal467 opened this issue Oct 25, 2024 · 1 comment · May be fixed by #8963
Open
1 task

Replace Hardcoded cy.wait() with cy.intercept in the cypress files #8925

nihal467 opened this issue Oct 25, 2024 · 1 comment · May be fixed by #8963
Assignees

Comments

@nihal467
Copy link
Member

Describe the bug

Currently there are multiple places in the cypress file, we use the hardcoded cy.wait(), it's creating a lot of flaky test across the test

Expected behavior

  • Replace the cywait() with cy.intercept (API request) or dynamic wait to ensure that flaky test are not occured

Screenshots

Image

@Rishith25
Copy link
Contributor

Rishith25 commented Oct 25, 2024

@nihal467 Is this the required solution for the above issue

Example:
Before:

verifyUploadFilePresence(fileName: string) {
    cy.wait(2000);
    cy.get("#file-div").scrollIntoView();
    cy.verifyContentPresence("#file-div", [fileName]);
  }

After:

verifyUploadFilePresence(fileName: string) {
    // Replace cy.wait(2000) with intercepting the file upload API call
    cy.intercept('POST', '/api/upload-file').as('fileUpload'); 
    cy.wait('@fileUpload'); // Wait for the file upload request to finish
    
    cy.get("#file-div").scrollIntoView(); 
    cy.verifyContentPresence("#file-div", [fileName]);
}

If this is correct I would like to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Triage
Development

Successfully merging a pull request may close this issue.

2 participants