Skip to content

4.8.0 Regression: Nested describes with before hook does not run final test #9026

@duttkin

Description

@duttkin

I am running into an issue with nested describes and cy.visit that causes the final test to either not actually execute or just return as successful. I tested this issue with 5.4 and 5.5 and it occurs in both versions. Below is a test that I used to reproduce the issue.

I would expect this test to fail on the last it block. I noticed a couple things when running this test in the GUI (running the open command). First the final test never gets a successful green check mark or red x for failure. The box is just there like it never ran but it will pass if run outside the gui which it should not pass. Second, if you watch the dev tools console in the GUI, the whole GUI will flash and the before which should have run just once will run again.

describe('Top level describe ', () => {
  before(() => {
    cy.request('https://www.cypress.io');
  });

  describe('Nested Describte 1', () => {
    beforeEach(() => {
      cy.visit('https://www.google.com');
    });

    it('should pass', () => {
      cy.location().should(loc => {
        expect(loc.origin).to.eq('https://www.google.com');
      });
      cy.get("#hplogo").should('be.visible');
    });

    it('should pass', () => {
      cy.location().should(loc => {
        expect(loc.origin).to.eq('https://www.google.com');
      });
      cy.get("#hplogo").should('be.visible');
    });

    it('should pass', () => {
      cy.location().should(loc => {
        expect(loc.origin).to.eq('https://www.google.com');
      });
      cy.get("#hplogo").should('be.visible');
    });
  });

  describe('Nested Describe 2', () => {
    beforeEach(() => {
      cy.visit('https://www.yahoo.com');
    });

    it('should fail', () => {
      cy.location().should(loc => {
        expect(loc.origin).to.eq('https://www.google.com');
      });
    });
  });
});

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions