mochaのbefore, beforeEach, after, afterEachの実行順番
(function () { describe('before test', function () { before(function(){ console.log('before'); }); beforeEach(function(){ console.log('beforeEach'); }); after(function () { console.log('after'); }); afterEach(function () { console.log('afterEach'); }); it('should show console.log', function () { console.log('test'); }); }); })();
上記のコードを実行すると下記の順番で実行される。
- before
- beforeEach
- test
- afterEach
- after