运行测试时出现npm error ELIFECYCLE [英] npm error ELIFECYCLE while running the test
问题描述
我正在使用mocha-phantomjs设置进行单元测试.我有以下package.json脚本来运行测试.
"scripts": {
"test": "npm run testFlickr",
"testFlickr": "mocha-phantomjs ./test/FlickrTest.html"
}
这在浏览器中可以正常运行.当我在cmd中运行命令npm test
时,测试运行正常,但它还会出现以下错误
3 passing (5s)
6 failing
npm ERR! flickr-test@ testFlickr: `mocha-phantomjs ./test/FlickrTest.html`
npm ERR! Exit status 6
npm ERR!
npm ERR! Failed at the flickr-test@ testFlickr script.
npm ERR! This is most likely a problem with the flickr-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mocha-phantomjs ./test/FlickrTest.html
npm ERR! You can get their info via:
npm ERR! npm owner ls flickr-test
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "testFlickr"
npm ERR! cwd C:\Users\user\Desktop\test
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\user\Desktop\test\npm-debug.log
npm ERR! not ok code 0
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
请任何人告诉我如何解决此错误.
当我在cmd中运行命令npm test时,测试运行正常
不,不是.您有6个失败的测试. 您的脚本设置很奇怪.您应该拥有: 然后,奇数节点错误应该消失. I am using mocha-phantomjs setup for unit testing. I have following package.json scriot to run the tests. This run ok in browser. And when I run the command Please can anyone tell me how can I resolve this error. And when I run the command npm test in cmd, the test run alright No they aren't. You have 6 failing tests. The exit code of Your script setup is odd. You should just have: Then the odd node errors should go away. 这篇关于运行测试时出现npm error ELIFECYCLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!mocha-phantomjs
的退出代码等于测试失败的次数.直接运行mocha-phantomjs ./test/FlickrTest.html
并查看失败的原因.意识到PhantomJS与您的浏览器有些不同-您可能"scripts": {
"test": "mocha-phantomjs ./test/FlickrTest.html"
}
"scripts": {
"test": "npm run testFlickr",
"testFlickr": "mocha-phantomjs ./test/FlickrTest.html"
}
npm test
in cmd, the test run alright but it also gives following error 3 passing (5s)
6 failing
npm ERR! flickr-test@ testFlickr: `mocha-phantomjs ./test/FlickrTest.html`
npm ERR! Exit status 6
npm ERR!
npm ERR! Failed at the flickr-test@ testFlickr script.
npm ERR! This is most likely a problem with the flickr-test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mocha-phantomjs ./test/FlickrTest.html
npm ERR! You can get their info via:
npm ERR! npm owner ls flickr-test
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "testFlickr"
npm ERR! cwd C:\Users\user\Desktop\test
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\user\Desktop\test\npm-debug.log
npm ERR! not ok code 0
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
mocha-phantomjs
is equal to the number of failing tests. Run mocha-phantomjs ./test/FlickrTest.html
directly and see what is failing. Realize the PhantomJS is a bit different than your browser - you may have to debug it."scripts": {
"test": "mocha-phantomjs ./test/FlickrTest.html"
}