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

Fixture File Reuse Causing Test Failures in Cypress Test Suite #29079

Open
TauqeerK18 opened this issue Mar 7, 2024 · 1 comment
Open

Fixture File Reuse Causing Test Failures in Cypress Test Suite #29079

TauqeerK18 opened this issue Mar 7, 2024 · 1 comment
Labels
stage: needs information Not enough info to reproduce the issue

Comments

@TauqeerK18
Copy link

TauqeerK18 commented Mar 7, 2024

Current behavior

I'm encountering an issue with reusing fixture files across multiple test cases within the same Cypress test suite. When attempting to use the same fixture file in different test cases, the third test case fails due to conflicts arising from fixture file reuse.

Desired behavior

All test cases must pass.

Test code to reproduce

describe("Test Cypress fixture file", () => {
    beforeEach(() => {
        cy.visit("https://test.com/");
        cy.wait(2000);
    });

    afterEach(() => {
        cy.clearCookies();
    })

    it("upload the file - test 1", () => {
        cy.xpath("//div[@id='utility']").click();
        cy.wait(2000);
        cy.fixture('Mytest.pdf', null).as('testFile');
        cy.xpath(
            "//label[@class='relative my-10 h-[45px] w-[276px]  cursor-pointer rounded-lg bg-cta-primary py-2 text-center text-xl font-semibold text-white md:block md:text-lg md:font-semibold lg:hidden']"
          ).selectFile('@testFile');
        cy.wait(2000);

        cy.xpath("//img[@alt='success']").should("be.visible");
    });

    it("upload the file - test 2", () => {
        cy.xpath("//div[@id='utility']").click();
        cy.wait(2000);
        cy.fixture('test.pdf', null).as('testFile');
        cy.xpath(
            "//label[@class='relative my-10 h-[45px] w-[276px]  cursor-pointer rounded-lg bg-cta-primary py-2 text-center text-xl font-semibold text-white md:block md:text-lg md:font-semibold lg:hidden']"
          ).selectFile('@testFile');
        cy.wait(2000);

        cy.xpath("//img[@alt='success']").should("be.visible");
    });

    it("upload the file - test 3", () => {
        cy.xpath("//div[@id='utility']").click();
        cy.wait(2000);
        cy.fixture('Mytest.pdf', null).as('testFile');
        cy.xpath(
            "//label[@class='relative my-10 h-[45px] w-[276px]  cursor-pointer rounded-lg bg-cta-primary py-2 text-center text-xl font-semibold text-white md:block md:text-lg md:font-semibold lg:hidden']"
          ).selectFile('@testFile');
        cy.wait(2000);

        cy.xpath("//img[@alt='success']").should("be.visible");
    });

})

It fails on selectFile() action, as the same fixture file is used two times in the same test suite.

Cypress Version

13.3.1

Node version

v18.17.1

Operating System

MacOS Sonoma 14

Debug Logs

xpath//label[@class='relative my-10 h-[45px] w-[276px] cursor-pointer rounded-lg bg-cta-primary py-2 text-center text-xl font-semibold text-white md:block md:text-lg md:font-semibold lg:hidden']
5
selectFile@testFile
6
wait2000

Other

No response

@jennifer-shehane
Copy link
Member

@TauqeerK18 What is the error you are seeing? Does the problem you're seeing sound like this existing issue? #4716

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs information Not enough info to reproduce the issue
Projects
None yet
Development

No branches or pull requests

2 participants