Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma auto-watch is not working

I've used Karma about 1 year ago and everything worked fine. When I changed the tests and saved the .test.js file, the test auto-ran - didn't have to restart or change anything. Today I wanted to run these tests again. Having a new computer, I had to install node and npm and whatnot, and then I installed also:

npm install -g karma karma-cli karma-jasmine karma-chrome-launcher

I configured Karma as follows (karma init):

    // Karma configuration
// Generated on Thu Apr 14 2016 14:50:35 GMT+0200 (Central Europe Summer Time)

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

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'js/*.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    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
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}

When I start karma (karma start karma.conf.js) a new chrome tab opened up, with the port, specified in the config file. The test ran, everything worked as expected. However, when I changed something in the .test.js file, Karma didn't autorun. Actually, no changes were made. I had to restart Karma in CMD and ran again in order to see the new results.

However, if I open a new CMD and execute karma run the test get updated. So, the part that watches for changes doesn't work, obviously.

So, I have no idea what I'm missing here, but auto-watch function of Karma is not working anymore. Any suggestions where I should start?

like image 560
uglycode Avatar asked Oct 19 '22 11:10

uglycode


1 Answers

I Just finally found the fix after months of looking.

I'm sure there are other ways to disable cache in chrome. But this worked for me right away.

Once you type karma start, and chrome launches, enable dev tools, and on the network tab, check disable cache

like image 137
Doug Chamberlain Avatar answered Nov 02 '22 09:11

Doug Chamberlain