mocha scope 之间执行顺序


TL;DR

describe('outer', function() {
    before(function() {
        print(`outer before`, )
    });

    after(function() {
        print(`outer after`, )
    });

    beforeEach(function() {
        print(`outer beforeEach`, )
    });

    afterEach(function() {
        print(`outer afterEach`, )
    })

    describe('inner', () => {
        before(function() {
            print(`inner before`, )
        })

        after(function() {
            print(`inner after`, )
        })

        beforeEach(function() {
            print(`inner beforeEach`, )
        })

        afterEach(function() {
            print(`inner afterEach`, )
        })

        it('it case', () => {
            print(`inner it case`, )
        })
    })
})

输出

result