21

I have had karma running using grunt on my application, but, for some reason, things stopped working. I updated karma with a re-install, which changed a lot, and changed my config file. All my files are being added and served, however it's not executing any of my tests.

For the time being (just to attempt to get things running again), I'm running outside of grunt, using the command karma start <pathtomyconfigfile>. Using the LOG_DEBUG option, I'm seeing everything Added and Served.

This is my config file:

module.exports = function(config) {
config.set({

    // base path, that will be used to resolve files and exclude
    basePath: '',


    // frameworks to use
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
        '../build/angular/angular.js',
        '../build/angular/angular-mocks.js',
        '../build/angular/angular-resource.js',
        '../build/angular/angular-cookies.js',
        '../build/angular/angular-scenario.js',
        '../src/**/*.js',
        '../dist/tmp/**/*.js',
        '../vendor/angular-bootstrap/*.js',
        '../vendor/angular-ui-utils/modules/route/*.js',
        '../vendor/angular-ui-utils/modules/mask/*.js'
    ],


    // list of files to exclude
    exclude: [

    ],


    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: ['progress'],


    // web server port
    port: 9018,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_DEBUG,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome'],//nothing so we can start it on our own


    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 60000,


    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
});
};

I'm at a loss here, ran on different browsers, changing the files watched, switched between the old way to load frameworks within the file variable to the framework variable... Any help will be greatly appreciated. Thanks!

Additional information

It also seems that my karma is erroring out with no information other than error:

INFO [karma]: Karma v0.10.1 server started at http://localhost:9018/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 28.0.1500 (Mac OS X 10.7.4)]: Connected on socket id sidUjYbbZINjGB_6wS6M
Chrome 28.0.1500 (Mac OS X 10.7.4): Executed 0 of 0 ERROR (0.777 secs / 0 secs)
jbenowitz
  • 1,785
  • 5
  • 25
  • 39
  • where are your tests located? are they nested somewhere in "../src/**/*.js"? – UnicodeSnowman Aug 21 '13 at 21:08
  • yes, they're all being served into the browser(noted by watching the debug lines). – jbenowitz Aug 21 '13 at 21:13
  • just to isolate things, are you able to do an iit on a single "guaranteed-to-pass" test and have it run? expect(true).toBe(true) or something similar? – UnicodeSnowman Aug 21 '13 at 21:23
  • Nope, I commented out all my specs, and ran a similar truth test. Still on that error. Strange. – jbenowitz Aug 21 '13 at 21:25
  • 2
    are you using angular-scenario? I vaguely remember having a similar issue when including angular-scenario.js in my config file. try removing it and see if that helps. – UnicodeSnowman Aug 21 '13 at 21:30
  • AH YOU'RE A GENIUS! Thank you very much. I know there was a reason I once added it (I'm assuming it helps with the scenario testing). Should I be worried to not have it on my build path? – jbenowitz Aug 21 '13 at 21:45
  • 2
    no, it's really only used for the e2e scenario tests. if you're e2e testing, you'll probably have a separate config file anyway. you don't need it for unit tests. – UnicodeSnowman Aug 21 '13 at 21:47
  • Great, thank you for your help. You saved me a day of work. – jbenowitz Aug 21 '13 at 22:00
  • I have just got similar problem. I solved putting *autowatch = true* in .conf and starting with *karma run*.. mumble mumble.. – Daniele Vrut Oct 28 '13 at 14:34

2 Answers2

42

If you are using angular-scenario, remove angular-scenario.js from your config file and see if that helps.

Matt
  • 70,063
  • 26
  • 142
  • 172
UnicodeSnowman
  • 1,609
  • 16
  • 13
3

Just spent a couple hours on this problem myself. Turned out I was using karma 0.10.3 and switching to 0.10.2 fixed the problem.

Try npm install karma@0.10.2 and see if that fixes anything!

Also make sure autoWatch is set to true in your config.

Matt
  • 70,063
  • 26
  • 142
  • 172
rennekon
  • 157
  • 2
  • 7
  • 1
    Setting autoWatch to 'true' fixed this issue for me. How do you run tests if autoWatch is set to false? Shouldn't the tests execute each time I start Karma? – seangwright Sep 24 '14 at 13:23
  • Late comment for anyone stumbling here: for one time test execution on karma start, use `singleRun: true`. autoWatch can be false in that case. – Kelo Jan 06 '16 at 14:14
  • The question is what has been added to 0.10.3 that made karma stop running the tests? – Willa Jun 04 '16 at 00:03
  • It is strange that this answer applied to my case! I was on 0.13.22 and I wasn't convinced downgrading would change anything but guess what it did!! I went to 0.13.0 and ta-da it works! – Willa Jun 04 '16 at 00:11