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

Created on 1 Jun 2018  Â·  3Comments  Â·  Source: cypress-io/cypress

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:

  • make it possible to toggle the skipped test open to show which hooks it ran
  • show the "before all" log in the first not-skipped test
  • show the "before all" log under the describe but outside of the it tests

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

[email protected], latest Chrome, macOS 10.13.4

pkreporter ready for work hooks ↪ unexpected behavior

Most helpful comment

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

All 3 comments

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...

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:

  - 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).

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbung picture rbung  Â·  3Comments

egucciar picture egucciar  Â·  3Comments

jennifer-shehane picture jennifer-shehane  Â·  3Comments

stormherz picture stormherz  Â·  3Comments

brian-mann picture brian-mann  Â·  3Comments