如何指定摩卡测试目录? [英] How to specify test directory for mocha?

查看:65
本文介绍了如何指定摩卡测试目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆