Change default timeout for mocha

后端 未结 4 973
臣服心动
臣服心动 2020-11-29 22:25

If we have a unit test file my-spec.js and running with mocha:

mocha my-spec.js

The default timeout will be 2000 ms. It can be overwritten

4条回答
  •  感情败类
    2020-11-29 23:21

    Adding this for completeness. If you (like me) use a script in your package.json file, just add the --timeout option to mocha:

    "scripts": {
      "test": "mocha 'test/**/*.js' --timeout 10000",
      "test-debug": "mocha --debug 'test/**/*.js' --timeout 10000"
    },
    

    Then you can run npm run test to run your test suite with the timeout set to 10,000 milliseconds.

提交回复
热议问题