我在 Mac High Sierra 上使用 [电子邮件受保护]。我想运行在此 Stratum 客户端项目 中设置的测试。我已经成功运行
npm install
。但是当我尝试运行单独的测试时,我收到错误:
no test specified
什么给予?我位于根项目目录中,测试位于我的“test”文件夹中。这是发生的事情:
localhost:stratum-client-master davea$ npm install
up to date in 0.381s
localhost:stratum-client-master davea$ npm test test/callbacks.js
> [email protected] test /Users/davea/Documents/workspace/stratum-client-master
> echo "Error: no test specified" && exit 1 "test/callbacks.js"
Error: no test specified
sh: line 0: exit: too many arguments
npm ERR! Test failed. See above for more details.
尝试更换
"scripts": {
"test": "mocha"
},
在你的
package.json
。
您所输出的内容正是 package.json 文件 被告知要输出的内容。看看下面
scripts
。
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"int-test": "mocha --require babel-core/register --recursive test"
},
尝试
int-test
,其中的另一个命令。
更新:包链接已更改为以下内容,mocha 应该是默认测试套件。您可以使用
npm run bump-version
运行其他脚本;上面的原始脚本可以使用 npm run int-test
. 运行
"scripts": {
"test": "mocha --recursive test",
"bump-version": "npm version patch"
},
您没有指定您正在使用哪个测试框架,例如
Jest
或Mocha
。
如果是开玩笑,请将其添加到您的
package.json
中:
"scripts" : {
"test" : "jest"
}
对于
mocha
,请参阅@Divyeshpal的回答。
错误可能是“exit 1”
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
改成这样:
"scripts": {
"test": "echo \"No test specified\""
},
此更改有效,因为退出 1 会产生错误。
如果您使用 Jest 和酶进行单元测试并且您有 jest.config.json 配置文件,则可以将脚本下的 package.json 更新为以下内容:
"scripts":{
"test": "jest --config=./jest.config.json --coverage",
}
错误可能是“exit 1”
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
改成这样:
"scripts": {
"test": "echo \"No test specified\""
},
此更改对我有用,因为 exit 1 创建了错误。
在 package.json 中查找并进行更改
“脚本”:{ “测试”:“摩卡” }
将其添加到您的packages.json文件中:
"scripts":{
"test": "mocha --ui tdd tests/callbacks.js",
}
然后在控制台上
npm test
。
我也遇到了这样的问题,我重复了(npm install selenium-webdriver)命令,之后一切就位了
更换
echo \"Error: no test specified\" && exit 1
在你的
package.json
和
mocha
。