How to set timeout on before hook in mocha?

后端 未结 4 1642
一生所求
一生所求 2021-01-03 17:32

I want to set timeout value on before hook in mocha test cases. I know I can do that by adding -t 10000 on the command line of mocha but this will change every

4条回答
  •  清酒与你
    2021-01-03 18:06

    Calling this.timeout(milliseconds); in the before hook is correct. Anyway, you need to use a regular function for the hook (function (done) ...) rather than an arrow function (done => ...).

    before(
        function(done) {
            this.timeout(10000);
            ...
        }
    );
    

    And the reason is that arrow functions have no this binding.

提交回复
热议问题