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

Before hook called multiple times inside one test block #17935

Closed
JohnnyTheBoy opened this issue Aug 30, 2021 · 2 comments
Closed

Before hook called multiple times inside one test block #17935

JohnnyTheBoy opened this issue Aug 30, 2021 · 2 comments

Comments

@JohnnyTheBoy
Copy link

Current behavior

when writing multiple tests inside one block (describe), before hook triggers multiple times.

Desired behavior

Before hook inside one block should be triggered only once.

Test code to reproduce

describe("Testing", () => {

before(() => {
    cy.log("Before hook is called!");
});

beforeEach(() => {
    cy.log("Before each hook is called");
});

it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });

it("says hi", () => {
    cy.visit("www.google.com");
    cy.log("Hi!");
});

it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });
it("do something", () => { expect(true).to.be.eq(true); });

});

Cypress Version

8.3.1

Other

No response

@JohnnyTheBoy
Copy link
Author

cypress_before_hook_issue

@jennifer-shehane
Copy link
Member

Looks like a duplicate of #17705 where hooks can be rerun in certain situations when there is a top navigation. We are working on this issue currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants