How to specify test directory for mocha?

后端 未结 14 1664
走了就别回头了
走了就别回头了 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:26

    Edit : This option is deprecated : https://mochajs.org/#mochaopts


    If you want to do it by still just running mocha on the command line, but wanted to run the tests in a folder ./server-tests instead of ./test, create a file at ./test/mocha.opts with just this in the file:

    server-tests
    

    If you wanted to run everything in that folder and subdirectories, put this into test/mocha.opts

    server-tests
    --recursive
    

    mocha.opts are the arguments passed in via the command line, so making the first line just the directory you want to change the tests too will redirect from ./test/

提交回复
热议问题