How to specify test directory for mocha?

后端 未结 14 1681
走了就别回头了
走了就别回头了 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 in node.js, some new configurations as of Mocha v6:

    Option 1: Create .mocharc.json in project's root directory:

    {
      "spec": "path/to/test/files"
    }
    

    Option 2: add mocha property in project's package.json:

    {
      ...
    
      "mocha": {
        "spec": "path/to/test/files"
      }
    }
    

    More options are here.

提交回复
热议问题