cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.67k stars 3.16k forks source link

Global hooks don't show up in test runner if first/last test are skipped #1846

Open simonhaenisch opened 6 years ago

simonhaenisch commented 6 years ago

Is this a Feature or Bug?

Bug

Current behavior:

image

The first test is shown as skipped in the test runner and is not collapsable, but the before hook gets executed within it (and thus it should show the "before all" log). There is no way to figure out through the UI whether the before hook was successfully executed.

Desired behavior:

image

Possible Solutions:

I'd prefer the third solution, since the before/after hooks don't really belong to any specific test.

Steps to reproduce:

before(cy.resetDatabase);

describe('test', () => {
  it.skip('first test', () => {});
  it('next test', () => {});
}

Versions

cypress@3.0.0, latest Chrome, macOS 10.13.4

brian-mann commented 6 years ago

If mocha is executing the before hook on a skipped test then that's actually a bug in Mocha (and who knows it may be an open issue somewhere).

Mocha isn't supposed to run hooks for tests it knows it's not going to run. For instance I know for sure that beforeEach and afterEach tests are not run...

simonhaenisch commented 6 years ago

Well, it's running the before hook before the first test, disregarding whether it's skipped or not... so I wouldn't really call it a bug (couldn't find anything in their issues), more of a design choice/issue maybe. I would think that before and after should actually be listed outside specific it() tests, while beforeEach and afterEach could still stay within the test context:

Test
  - BEFORE ALL
  - First Test (skipped)
  - Second Test
    - BEFORE EACH
    - ASSERT
    - LOG blah blah
    - AFTER EACH
  - AFTER ALL

If you're saying that your reporting style is based on Mocha's, then yeah I could report it as an upstream issue to "fix" in their reporter (if they consider it a bug).

SergeyKuryatnick commented 5 years ago

The same issue is reproduced for the AFTER ALL hook. If last IT is skipped - AFTER ALL works, but not shown in the test runner

Rebaiahmed commented 1 year ago

Hey, any update about this issue?

maydrori commented 1 year ago

Is there any update? It is still reproduced on cypress 11

cypress-app-bot commented 1 year ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot commented 11 months ago

This issue has been closed due to inactivity.