首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行测试时npm错误ELIFECYCLE

运行测试时npm错误ELIFECYCLE
EN

Stack Overflow用户
提问于 2014-04-25 06:48:22
回答 4查看 27.7K关注 0票数 26

我使用摩卡-幻影设置为单元测试。我已经跟随package.json脚本来运行测试。

代码语言:javascript
复制
"scripts": {
"test": "npm run testFlickr",
"testFlickr": "mocha-phantomjs ./test/FlickrTest.html" 
}

在浏览器中运行正常。当我在cmd中运行命令npm test时,测试运行正常,但它也给出了以下错误

代码语言:javascript
复制
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

请任何人告诉我如何解决这个错误。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2014-04-25 15:05:15

当我在cmd中运行命令npm测试时,测试运行正常。

不,他们不是。你有6次考试不及格。mocha-phantomjs的退出代码等于失败测试的数量。直接运行mocha-phantomjs ./test/FlickrTest.html,看看失败了什么。意识到PhantomJS和你的浏览器有点不同--你可以使用必须调试它

你的脚本设置很奇怪。你应该有:

代码语言:javascript
复制
"scripts": {
   "test": "mocha-phantomjs ./test/FlickrTest.html"
}

那么奇怪的节点错误就会消失。

票数 6
EN

Stack Overflow用户

发布于 2018-02-23 04:10:21

我也遇到了同样的问题,当我运行我的单元测试时,而不是使用了它。

代码语言:javascript
复制
npm run test

代替使用:

代码语言:javascript
复制
npm test
票数 31
EN

Stack Overflow用户

发布于 2015-11-05 00:16:10

在运行npm test时,它会压制ELIFECYCLE错误,因此您永远不会遇到这种体验。

引用代码

一旦将测试脚本移动到不同的脚本名,就会开始看到ELIFECYCLE错误。

我的解决办法是在命令的末尾添加一个exit 0。对于您的代码,它将如下所示:

代码语言:javascript
复制
"scripts": {
  "test": "npm run testFlickr",
  "testFlickr": "mocha-phantomjs ./test/FlickrTest.html; exit 0" 
}
票数 22
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23286017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档