如何指定摩卡测试目录? [英] How to specify test directory for mocha?
问题描述
Mocha 尝试在默认情况下在test
下查找测试文件,如何指定另一个目录,例如server-test
?
Mocha tries to find test files under test
by default, how do I specify another dir, e.g. server-test
?
推荐答案
不建议使用此选项: https://mochajs.org/#mochaopts
如果要通过仍然仅在命令行上运行mocha
来执行此操作,但又想在./server-tests
文件夹而不是./test
文件夹中运行测试,请在./test/mocha.opts
处创建一个文件文件:
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
如果要运行该文件夹和子目录中的所有内容,请将其放入test/mocha.opts
If you wanted to run everything in that folder and subdirectories, put this into test/mocha.opts
server-tests
--recursive
mocha.opts
是通过命令行传递的参数,因此使第一行也就是您要更改测试的目录也将从./test/
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/
这篇关于如何指定摩卡测试目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!