Bug

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.

Possible Solutions:
describe but outside of the it testsI'd prefer the third solution, since the before/after hooks don't really belong to any specific test.
before(cy.resetDatabase);
describe('test', () => {
it.skip('first test', () => {});
it('next test', () => {});
}
[email protected], latest Chrome, macOS 10.13.4
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
Most helpful comment
The same issue is reproduced for the
AFTER ALLhook.If last
ITis skipped -AFTER ALLworks, but not shown in the test runner