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

When action in before() hook fails, the initial test displays as a failure in the Cypress console instead of the before() hook #31012

Closed
eraugradep opened this issue Feb 3, 2025 · 2 comments

Comments

@eraugradep
Copy link

eraugradep commented Feb 3, 2025

Current behavior

When a cypress spec has a before() hook and it fails, the first it() displays as a fail.

Desired behavior

When a cypress spec has a before() hook and it fails, the before() hook displays as a fail and the first it() displays as skipped.

Image

Tester would think there was a failure in test 1 instead of the prerequisite setup:

Image

Test code to reproduce

describe('My First Test', () => {
  before(() => {
    expect(true).to.equal(false)
  })
  
  it('test #1', () => {
    cy.log('Test 1')
  })
  
  it('test #2', () => {
    cy.log('Test 2')
  })

})

Cypress Version

12.17.4

Node version

18.20.6

Operating System

Windows 11 Enterprise v22H2

Debug Logs

Other

No response

@jennifer-shehane
Copy link
Member

This is expected behavior. We have to generate a test to insert the failure into to fail with this status.

@jennifer-shehane jennifer-shehane closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
@eraugradep
Copy link
Author

I disagree, test #1 did not fail in the scenario above.

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