node.js - karma 测试通过,但 npm 测试给出错误

标签 node.js unit-testing angular npm karma-runner

我用https://github.com/AngularClass/angular2-webpack-starter并有以下问题:当我在项目目录中并运行时

karma start

然后我得到:

SUMMARY:

✔ 0 tests completed

但是当我运行时:

npm test

我得到:

SUMMARY:

✔ 0 tests completed

npm ERR! Test failed. See above for more details.

如果我运行:

npm run test

我得到:

SUMMARY:
✔ 0 tests completed

npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/7.1.0/bin/node" "/usr/local/bin/npm" "run" "test"
npm ERR! node v7.1.0
npm ERR! npm  v4.0.2
npm ERR! code ELIFECYCLE
npm ERR! angular2-webpack-starter@5.0.5 test: `karma start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the angular2-webpack-starter@5.0.5 test script 'karma start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-webpack-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     karma start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular2-webpack-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular2-webpack-starter
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Kamil/Desktop/Code/officewise/officewise_frontend/npm-debug.log

知道如何删除此 npm 错误吗?这对我来说很重要,因为我使用一些外部系统来运行测试并报告存储库中新提交的错误(我的 Node 版本 v7.1.0(最新)、npm 版本 4.0.2(最新)、Mac OS Sierra)。

最佳答案

默认情况下,如果没有要运行的测试,Karma 将退出并显示错误。

要禁用此行为,您需要将此行添加到您的 Karma 配置中:

failOnEmptyTestSuite: false

关于node.js - karma 测试通过,但 npm 测试给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40656858/

相关文章:

css - Angular Material 更改默认字体颜色

java - Apache ActiveMQ 配置

Android Kotlin 单元测试失败并出现 io.mockk.MockKException : no answer found for

angular - 如何检查是否有人订阅了 Angular 中的 EventEmitter?

javascript - Angular 2 : making an iframe src safe using a directive

.net - 对声明为友元的类进行单元测试(内部)

node.js - firebase 重写子域

Javascript:使用额外的花括号解析 JSON

javascript - 如何从客户端发送 Firebase token 并在 server.js 中接收它

c# - 如何模拟 Visual Studio 自动生成的 SOAP 客户端?