如何为 mocha 指定测试目录? [英] 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/
这篇关于如何为 mocha 指定测试目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!