Mantisimo
Mantisimo

Reputation: 4283

Karma Autowatch not working

Hi I have the following configuration and simple test, I run karma by typing 'karma start' . It runs and passes successfully, however, when I edit and save the simpletest.js file nothing happens...

Any idea why? I have autoWatch set to true and singleRun set to false.

Simpletest.js

    describe("my simple test", function() {
        it("should have an expected result", function() {
            expect(true).to.be.true;
        });
    });

Karma.conf.js

// Karma configuration
// Generated on Wed Feb 19 2014 22:59:38 GMT+0000 (GMT)

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

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

    // frameworks to use
    frameworks: ['mocha' , 'sinon-chai'],

    // list of files / patterns to load in the browser
    files: [
        'simpletest.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: 9876,


    // 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_INFO,


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


    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera (has to be installed with `npm install karma-opera-launcher`)
    // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
    // - PhantomJS
    // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
    browsers: ['Chrome'],


    // 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,

    client: {
      mocha: {
        ui: 'bdd'
      }
    }
  });
};

When running with logLevel: config.LOG_DEBUG enabled

DEBUG [plugin]: Loading karma-* from c:\dev\karmaspike\node_modules
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-coffee-preprocessor.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-firefox-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-html2js-preprocessor.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-mocha.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-phantomjs-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-requirejs.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-script-launcher.
DEBUG [plugin]: Loading plugin c:\dev\karmaspike\node_modules/karma-sinon-chai.
INFO [karma]: Karma v0.10.9 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [launcher]: Creating temp dir at C:\Users\Mantisimo\AppData\Local\Temp\karma-76378892
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\Kevin\AppData\Loc
al\Temp\karma-76378892 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --start
-maximized http://localhost:9876/?id=76378892
DEBUG [watcher]: Resolved files:
        c:\dev\karmaspike\node_modules/karma-sinon-chai/bower_components/sinonjs/sinon.js
        c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/chai/chai.js
        c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/sinon-chai/lib/sinon-chai.js
        c:\dev\karmaspike\node_modules/karma-sinon-chai/adapter.js
        c:\dev\karmaspike\node_modules/mocha/mocha.js
        c:\dev\karmaspike\node_modules/karma-mocha/lib/adapter.js
        c:\dev\karmaspike\simpletest.js
DEBUG [watcher]: Watching "c:\dev\karmaspike\simpletest.js"
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules\karma\static/client.html
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules\karma\static/karma.js
DEBUG [karma]: A browser has connected on socket PQ8_7xQOVC4GgFVebJZU
INFO [Chrome 32.0.1700 (Windows)]: Connected on socket PQ8_7xQOVC4GgFVebJZU
DEBUG [karma]: All browsers are ready, executing
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules\karma\static/context.html
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/chai/chai.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/bower_components/sinonjs/sinon
.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/node_modules/sinon-chai/lib/si
non-chai.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-sinon-chai/adapter.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/mocha/mocha.js
DEBUG [web-server]: serving: c:\dev\karmaspike\node_modules/karma-mocha/lib/adapter.js
DEBUG [web-server]: serving: c:\dev\karmaspike\simpletest.js
Chrome 32.0.1700 (Windows): Executed 1 of 1 SUCCESS (0.287 secs / 0 secs)

Upvotes: 1

Views: 1029

Answers (1)

Sharath
Sharath

Reputation: 969

Shouldn't base path be a relative path.. Something like basePath : './' so that it looks for the files in the same directory as the config?

Have u tried putting a console log in your test and setting karma to output debug log statements? That can tell you if the test is being run or not..

logLevel: config.LOG_DEBUG,

Upvotes: 0

Related Questions