为什么Karma在没有错误消息的情况下失败 - 没有运行测试

时间:2016-10-13 20:44:30

标签: angularjs karma-runner yeoman-generator gulp-karma

我正在运行一个相当复杂的前端堆栈。我正在使用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

1 个答案:

答案 0 :(得分:0)

经过一些实验和挫折后,我发现如果没有测试运行,Karma会失败(显然是设计),没有任何明确的错误信息。

如果没有测试通过,也会发生同样的失败 - 即使你把x放在他们故意绕过这些测试的时候也会发生。

基本上你需要至少进行一次通过测试,否则你会得到这个错误而没有明确解释原因。