javascript - mocha 错误:未找到测试文件:“test/”npm ERR!测试失败
问题描述
我正在尝试在 linux > @test C:\Users\wd.ssh\tel\qa_test\mocha-api-tests 上运行 mocha 测试
错误:未找到测试文件:“test/”npm ERR!测试失败。有关更多详细信息,请参见上文。
这是我的 package.json
{
"scripts": {
"test": "mocha --reporter mocha-junit-reporter --timeout 60000 --exit",
},
"dependencies": {
"cassandra-driver": "3.5.0",
"chai": "4.2.0",
"chai-http": "4.2.0",
"express": "4.16.4",
"mocha-junit-reporter": "1.18.0",
"request-promise": "4.2.2"
}
}
使用的命令: npm install --global mocha npm i 并运行我正在使用的测试 npm test
项目结构:
解决方案
看到你的项目结构,似乎你有一个test.js
所以 mocha 应该以这个文件为目标。
"scripts": {
"test": "mocha test.js --reporter mocha-junit-reporter --timeout 60000 --exit",
},
如果要添加更多测试文件,最好将它们放在测试目录中,例如/test
,必须将目标更改为目录中的测试文件。
"scripts": {
"test": "mocha 'test/**/*.js' --recursive --reporter mocha-junit-reporter --timeout 60000 --exit",
},
希望能帮助到你
推荐阅读
- opencv - 在树莓派上使用 cmake 构建 opencv 时出错
- r - 如何根据给定字符的一次或多次出现来拆分字符串?
- python - “ModuleNotFoundError: No module named 'numpy'”,但我已经安装了 NumPy
- reactjs - 使用侧边栏组件反应参数路由
- javascript - 如何使 useEffect 对 props 的反应与 ComponentDidUpdate 一样快?
- ruby-on-rails - 将带有数组的哈希存储为rails中的值
- ios - iOS Swift - URLSessionDataTask 在刷新时没有得到更新的 JSON 数据
- java - 在 kotlin 中将 String 转换为 JsonObject 返回 null
- python - 有没有办法获取特定电子邮件 ID 的 ID?
- css - 样式输入类型编号