- All
before
block run first in top down order - Then all
beforeEach
blocks run in top down order - Then all the
afterEach
blocks run in top down order - Finally all the
after
blocks run in top down order
This is from before.js gist:
describe('mocha before hooks', function () {
before(() => console.log('*** top-level before()'));
beforeEach(() => console.log('*** top-level beforeEach()'));
describe('nesting', function () {
before(() => console.log('*** nested before()'));
beforeEach(() => console.log('*** nested beforeEach()'));
it('is a nested spec', () => true);
});
});
mocha before hooks *** top-level before() nesting *** nested before() *** top-level beforeEach() *** nested beforeEach() ✓ is a nested spec 1 passing (8ms)