为什么 Karma 在这里失败而没有错误消息 - 没有测试 运行

Why is Karma failing here without an error message - no test being run

我运行宁宁一个相当复杂的前端堆栈。我正在使用 node、gulp、webpack 和 angular 1.5 with ES6.

我使用你的喷泉生成器设置我的项目。

我写了一些测试(失败了)但注意到我遇到了另一个意外失败 - 所以我删除了所有测试。 Karma 再次让我失败(尽管没有测试 运行),我不确定为什么。

它看起来可能在内部抛出异常并将其解释为失败的测试,但我对 Karma 的了解还不够,无法真正了解。

下面是 运行宁 gulp 测试的完整打印输出。任何人都知道会导致这种情况的原因。

[21:38:56] Loading /Users/samredway/Development/crunchboards/cb-admin-panel/frontend/gulp_tasks/browsersync.js
[21:38:56] Loading /Users/samredway/Development/crunchboards/cb-admin-panel/frontend/gulp_tasks/karma.js
[21:38:56] Loading /Users/samredway/Development/crunchboards/cb-admin-panel/frontend/gulp_tasks/misc.js
[21:38:56] Loading /Users/samredway/Development/crunchboards/cb-admin-panel/frontend/gulp_tasks/webpack.js
[21:38:57] Using gulpfile ~/Development/crunchboards/cb-admin-panel/frontend/gulpfile.js
[21:38:57] Starting 'test'...
[21:38:57] Starting 'karma:single-run'...
13 10 2016 21:39:01.686:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
13 10 2016 21:39:01.688:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
13 10 2016 21:39:01.693:INFO [launcher]: Starting browser PhantomJS
13 10 2016 21:39:02.717:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#iN8DZHviSAx3aI7RAAAA with id 42155207
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
[21:39:02] 'karma:single-run' errored after 5.79 s
[21:39:02] Error: Failed 1 tests.
    at failCount (/Users/samredway/Development/crunchboards/cb-admin-panel/frontend/gulp_tasks/karma.js:13:22)
    at removeAllListeners (/Users/samredway/Development/crunchboards/cb-admin-panel/frontend/node_modules/karma/lib/server.js:379:7)
    at Server.<anonymous> (/Users/samredway/Development/crunchboards/cb-admin-panel/frontend/node_modules/karma/lib/server.js:390:9)
    at Server.g (events.js:286:16)
    at emitNone (events.js:91:20)
    at Server.emit (events.js:185:7)
    at emitCloseNT (net.js:1549:8)
    at _combinedTickCallback (internal/process/next_tick.js:71:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
[21:39:02] 'test' errored after 5.79 s

经过一些实验和挫折后,我发现如果没有测试 运行.

,Karma 会失败(显然是设计使然)并且没有任何明确的错误消息

如果没有测试通过,也会发生同样的故障 - 即使您在它们旁边放一个 x 以故意绕过这些测试。

基本上您需要至少通过一项测试,否则您会收到此错误且没有明确解释原因。