angularjskarma-runneryeoman-generatorgulp-karma

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


I am running a fairly complicated front end stack. I am using node, gulp, webpack, and angular 1.5 with ES6.

I set up my project using yo fountain generator.

I wrote some tests (which failed) but noted that I was getting another unexpected fail - so I removed all the tests. Again Karma gave me a fail (although there are no tests being run) and I'm not sure why.

It looks potentially like it is throwing an exception internally and interpreting that as a failed test, but I don't know enough about Karma to really know.

Below is the complete print out from running gulp test. Anybody know what would cause this.

[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

Solution

  • After some experimentation and frustration, I found that Karma fails (apparently by design) without any clear error message if there are no tests run.

    This same failure occurs if no tests pass - even if you put an x by them to deliberately bypass those tests.

    Basically you need to have at least one passing test or you get this error with no clear explanation as to why.