Global `before` and `beforeEach` for mocha?

后端 未结 5 961
长情又很酷
长情又很酷 2021-02-01 00:38

I\'m using mocha for javascript unit-testing now.

I have several test files, each file has a before and beforeEach, but they are exactly the s

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 01:06

    In the root of the test folder, create a global test helper test/helper.js which has your before and beforeEach

    // globals
    global.assert = require('assert');
    
    // setup
    before();
    beforeEach();
    
    // teardown
    after();
    afterEach();
    

提交回复
热议问题