当前位置: 首页 > 面试题库 >

运行测试时出现npm错误ELIFECYCLE

巫欣荣
2023-03-14
问题内容

我正在使用mocha-phantomjs设置进行单元测试。我有以下package.json脚本来运行测试。

"scripts": {
"test": "npm run testFlickr",
"testFlickr": "mocha-phantomjs ./test/FlickrTest.html" 
}

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

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个失败的测试。的退出代码mocha-phantomjs等于测试失败的次数。mocha-phantomjs ./test/FlickrTest.html直接运行,看看有什么问题。意识到PhantomJS与您的浏览器有些不同-
您可能必须对其进行调试。

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

"scripts": {
   "test": "mocha-phantomjs ./test/FlickrTest.html"
}

然后,奇数节点错误应消失。



 类似资料:
  • 我刚刚添加了测试单元,当我使用运行它时,我得到了错误,测试将失败。但是,当我运行时,一切看起来都很好,我不知道发生了什么黑客。我认为当我使用运行时,无法识别部分文件,并将抛出新的错误。 这是我的代码https://github.com/rohmanhm/unobuilder/tree/test 下面是错误消息。 rohmanhm~/desktop/code/works/unobuilder tes

  • 问题内容: 当我尝试在Chrome中运行测试时出现此错误: 初始化方法AutomationUsingSelenium.SmuladorChrome.MyTestInitialize引发异常。OpenQA.Selenium.DriverServiceNotFoundException:OpenQA.Selenium.DriverServiceNotFoundException 原因是什么? 问题答案

  • 我是新来的节点,有点超出我的深度。在Mac OS X和Centos 6上都遇到此错误。发生在我尝试过的所有npm install xxx命令中。任何关于如何避免这一错误的建议都将不胜感激。 类似于npm,安装时会出现节点gyp错误,但我的用户名中没有空格,这就解决了他的问题。

  • 我遵循了本教程: 1.节点安装-node-v8.9.0-x86 2. ran命令 谢谢你,

  • 文件"C:\Program Data\Anaconda3\Script\tensorboard-script.py",第10行,sys.exit(run_main())文件"C:\Program Data\Anaconda3\lib\site-包\拉伸板\main.py",第57行,run_mainapp.run(tensorboard.main,flags_parser=tensorboard.

  • 当我运行codeception测试用例时,我的日志文件中出现了这个错误。如何解决这个问题? 代码: 命令: ./vendor/bin/codecept run tests/functional/AdminPhoneTestCest.php:testUpdatePhone 日志文件中的错误: [2015-06-06 05:34:02]本地的。错误:异常'照明\会话\令牌错配异常'在 /var/www