Skip to content

Instantly share code, notes, and snippets.

@armw4
Last active January 9, 2020 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save armw4/0344468bc84363ce570e to your computer and use it in GitHub Desktop.
Save armw4/0344468bc84363ce570e to your computer and use it in GitHub Desktop.
Having no specs is an error in karma.

by Antwan Wimberly

So I'm setting up my first project using gulp, karma, and jasminejs. I setup my karma task, and after repeatedly banging my head against my desk, I finally managed to get everything properly configured....or so I thought. It seemed like all the errors and warnings I'd encountered had been resovled (and they were). But for some reason, when I ran the task, I kept getting this output:

[13:03:58] Starting 'clean'...
[13:03:58] Finished 'clean' after 3.28 ms
[13:03:58] Starting 'files:scripts'...
[13:03:58] Starting 'files:specs'...
[13:03:58] Finished 'files:scripts' after 37 ms
[13:03:58] Finished 'files:specs' after 32 ms
[13:03:58] Starting 'karma'...
[13:03:58] Starting Karma server...
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket HmbQnsfd1llohVFPL5nu with id 26109259
PhantomJS 1.9.7 (Mac OS X): Executed 0 of 0 ERROR (0 secs / 0 secs)

/Users/axw2/Projects/ng-session-timeout/Gulpfile.coffee:116
      throw e;
            ^
Error: karma exited with code 1
  at done (/Users/axw2/Projects/ng-session-timeout/node_modules/gulp-karma/index.js:56:30)
  at ChildProcess.<anonymous> (/Users/axw2/Projects/ng-session-timeout/node_modules/gulp-karma/index.js:82:7)
  at ChildProcess.EventEmitter.emit (events.js:98:17)
  at Process.ChildProcess._handle.onexit (child_process.js:807:12)

➜  ng-session-timeout git:(master) ✗ 

As you can see, all you get back is a cryptic error stating that karma exited with code 1. Huh? But why? It was clear to me that no specs were executing, but that my intent. Surely this can't be the reason London Bridge is falling down. So I did some googling and tweaked a few things, but to no avail. Same error!! Finally I thought...

"Hmm....I wonder what will happen if I do this..."

describe "I'm in a big house bro", ->
  beforeEach ->
    console.log 'holy grail baaather'

  it 'should be 14', ->
    expect(14).toEqual 14

Next thing you know...

➜  ng-session-timeout git:(master) ✗ gulp karma --verbose
[13:09:14] Requiring external module coffee-script/register
[13:09:22] Using gulpfile ~/Projects/ng-session-timeout/Gulpfile.coffee
[13:09:22] Starting 'clean'...
[13:09:22] Finished 'clean' after 2.56 ms
[13:09:22] Starting 'files:scripts'...
[13:09:22] Starting 'files:specs'...
[13:09:22] Finished 'files:scripts' after 40 ms
[13:09:22] Finished 'files:specs' after 37 ms
[13:09:22] Starting 'karma'...
[13:09:22] Starting Karma server...
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket 9AJ-Izyl5qqUeEGlNIjf with id 53695240
LOG: 'holy grail baaather'
PhantomJS 1.9.7 (Mac OS X): Executed 1 of 1 SUCCESS (0.003 secs / 0.006 secs)
[13:09:25] Finished 'karma' after 3.58 s
➜  ng-session-timeout git:(master) ✗ 

"Aaaaaaaaaaaaaaand we're Gucci"

@desertedisland
Copy link

OMG thanks!

@hardikkaji
Copy link

Hey Thanks. It helped a lot. 👍

@armw4
Copy link
Author

armw4 commented Jan 9, 2020

You're welcome guys!!! @hardikkaji and @desertedisland! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment