How to specify test directory for mocha?

后端 未结 14 1668
走了就别回头了
走了就别回头了 2020-12-04 05:59

Mocha tries to find test files under test by default, how do I specify another dir, e.g. server-test?

14条回答
  •  悲&欢浪女
    2020-12-04 06:23

    If you are using nodejs, in your package.json under scripts

    1. For global (-g) installations: "test": "mocha server-test" or "test": "mocha server-test/**/*.js" for subdocuments
    2. For project installations: "test": "node_modules/mocha/bin/mocha server-test" or "test": "node_modules/mocha/bin/mocha server-test/**/*.js" for subdocuments

    Then just run your tests normally as npm test

提交回复
热议问题