Skip to content

Instantly share code, notes, and snippets.

@armw4
Last active January 4, 2016 14:49
Show Gist options
  • Save armw4/8636683 to your computer and use it in GitHub Desktop.
Save armw4/8636683 to your computer and use it in GitHub Desktop.
BEWARE: Using the background key in your grunt-karma (as of v0.6.2) config will suppress any runtime errors.

###by Antwan Wimberly###

I had this config setup (remainder of config left out for brevity...am using grunt-contrib-watch just like in the README):

module.exports = (grunt) ->
  grunt.initConfig
    pkg: grunt.file.readJSON 'package.json'
    karma:
      unit:
        configFile: 'karma.config.coffee'
        background: true

I actually spelled the name of the configFile wrong. It's supposed to be karma.conf.coffee. After seeing karma do absolutely nothing, grunt repeatedly tell me "Done, without errors" and giving me a false sense of success, and about 50 face palms, I was curious as to what would happen when I ran the task without background:true. Finally I saw the light:

ERROR [config]: File /Users/antwanwimberly/SourceCode/auth-demo/karma.config.coffee does not exist!

So the only sane way to debug your karma setup is to defer setting the background:true key until you've managed to stabilize your configuration and witness your tests being run successfully.

@armw4
Copy link
Author

armw4 commented Jan 26, 2014

Using PhamtomJS (headless browser) also didn't help since it doesn't render to the display like Chrome or Firefox. If I were using either of those two browsers, I may have noticed an issue sooner rather than later. Keep that in mind as well.

@armw4
Copy link
Author

armw4 commented Jan 26, 2014

Also this wishful bit of thinking does not work:

grunt.registerTask 'default', ['karma:unit:start watch'];

With the above setup, I expected to be able to simply type grunt from the command line and all would be well. Well....NO! You literally have to type out grunt karma:unit:start watch from your terminal in order for everything to work as desired.

UPDATE: Just found a way to get this to work without explicitly invoking from the command line. All done via grunt task now.

@DannyDouglass
Copy link

Hmmmm, that's surprising that you have to type that full command out. Is this one of your public repos?

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