question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AutoWatch doesn't work

See original GitHub issue

If I run:

karma start karma.conf.js --auto-watch --browsers Chrome --runner-port 9090 --no-single-run

Karma doesn’t react to file changes. Here are relevant files: package.json:

{
    "name": "test-app",
    "version": "0.1.0",
    "devDependencies": {
        "connect-modrewrite": "0.5.11",
        "findup-sync": "0.1.2",
        "grunt": "0.4.2",
        "grunt-angular-templates": "0.5.1",
        "grunt-autoprefixer": "0.6.4",
        "grunt-check-dependencies": "0.3.0",
        "grunt-concurrent": "0.4.3",
        "grunt-continue": "0.0.1",
        "grunt-contrib-clean": "0.5.0",
        "grunt-contrib-compass": "0.7.0",
        "grunt-contrib-concat": "0.3.0",
        "grunt-contrib-connect": "0.6.0",
        "grunt-contrib-copy": "0.5.0",
        "grunt-contrib-htmlmin": "0.1.3",
        "grunt-contrib-jshint": "0.7.2",
        "grunt-contrib-uglify": "0.3.1",
        "grunt-contrib-watch": "0.5.3",
        "grunt-csso": "0.5.3",
        "grunt-ddescribe-iit": "0.0.4",
        "grunt-defs": "0.6.1",
        "grunt-jsonlint": "1.0.4",
        "grunt-karma": "0.6.2",
        "grunt-merge-conflict": "0.0.2",
        "grunt-newer": "0.6.1",
        "grunt-ng-annotate": "0.0.4",
        "grunt-notify": "0.2.17",
        "grunt-protractor-runner": "0.2.1",
        "grunt-rev": "0.1.0",
        "grunt-shell": "0.6.2",
        "grunt-usemin": "2.0.2",
        "jasmine-reporters": "0.2.1",
        "karma": "0.10.9",
        "karma-chrome-launcher": "0.1.2",
        "karma-coverage": "0.1.4",
        "karma-firefox-launcher": "0.1.3",
        "karma-jasmine": "0.1.5",
        "karma-junit-reporter": "0.2.1",
        "karma-ng-json2js-preprocessor": "0.0.5",
        "karma-opera-launcher": "0.1.0",
        "libxmljs": "0.8.1",
        "load-grunt-tasks": "0.2.1",
        "protractor": "0.16.1"
    }
}

karma.conf.js:

'use strict';

module.exports = function (config) {
    require('./karma-shared.conf')(config);

    config.set({
        // list of files / patterns to load in the browser
        files: config.files.concat([
            'app/vendor/l20n-*/l20n.js',
            'app/vendor/jquery-*/jquery.js',
            'app/vendor/lodash-*/lodash.custom.js',
            'app/vendor/modernizr-*/modernizr-custom.js',
            'app/vendor/bootstrap-*/bootstrap.js',
            'app/vendor/bootstrap-tagsinput/bootstrap-tagsinput.js',
            'app/vendor/typeahead.js-*/typeahead.js',
            'app/vendor/seadragon/seadragon.js',

            'app/vendor/angular-*/angular/angular.js',
            'app/vendor/angular-*/angular-*/angular-*.js',

            'app/vendor/placeholders-*/placeholders-*.js',
            'app/vendor/ng-l20n/ng-l20n.js',
            'app/vendor/google-analytics/tracking-code.js',
            'app/vendor/angulartics-0.8.5/angulartics.js',
            'app/vendor/ng-tags-input-8d243e5ad0-fork/ng-tags-input.js',

            'app/lib/polyfill.defs.js',
            'app/lib/key_codes.defs.js',
            'app/lib/jquery.dotdotdot-1.5.6-modified.defs.js',

            'app/cbn-modules/**/*.defs.js',
            'app/app.defs.js',

            'test/templates.js',
        ]).concat(config.bottomFiles),

        exclude: config.exclude.concat([
            'app/**/*.min.js',
        ]),
    });
};

karma-shared.conf.js:

'use strict';

module.exports = function (config) {
    var preprocessors = config.preprocessors;
    preprocessors['**/*.json'] = 'json2js';

    config.set({
        frameworks: ['jasmine'],
        basePath: '',
        files: [
            'test/settings.js',
        ],
        bottomFiles: [
            'test/mocks-inlined/*.json',
            'test/vendor/**/*.js',
            'test/{lib,mock,unit}/**/*.defs.js',
        ],
        exclude: [],
        preprocessors: preprocessors,
        plugins: config.plugins.concat([
            'karma-ng-json2js-preprocessor',
        ]),
        reporters: ['progress'],
        port: 8080,
        runnerPort: 9100,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: false,
        browsers: ['Chrome', 'Firefox'],
        captureTimeout: 60000,
        singleRun: true,
    });
};

Watched *.defs.js files are generated via grunt-defs. Once a file is generated, Karma doesn’t pick up the change and doesn’t dispatch the tests.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:33 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
nazandreycommented, Jul 12, 2017

Hello all! I was searching why karma doesnt reload when file is changed. Now after 3-5 days of deep research i finally found a reason for this.

It’s not autoWatch, nor usePolling, nor singleRun, nor atomic_save for me.

It’s glob characters in the full path to watched file (in my case it was like C:\!JS\foo\bar.js, notice ‘!’ in the beggining of JS). Reason for this here (https://github.com/paulmillr/chokidar/issues/300 (issue from chokidar, which karma has in dependencies)). So consider to check names of your current working directory and files for ‘!’, ‘*’, ‘[’, ‘{’ and etc.

Hope it helps to save a lot of time for someone because i would be really glad to find my message in the past.

p.s. I decided to write message exactly here because it was the most common page which i was landing during my research 😃

3reactions
pallogucommented, May 2, 2014

I had the same issue on Intellij. It looks like you have to disable Use ‘safe write’ setting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autowatch does not work | Jira Service Management Server ...
The user is not added as a watcher. Workaround. From the System Service Desk Addon disable the sd-auto-watch-predicate-impl module. Then Autowatch feature works ......
Read more >
Autowatch diagnostic codes - Obsessive Vehicle Security Blog
Most Autowatch alarms lack information about how to find alarm fault codes their user manuals. This makes troubleshooting very difficult for ...
Read more >
Ghost - Problems with stop / start - Autowatch
Start and drive normally without entering service mode. · Confirm that stop/start is not working as expected. · Stop somewhere and put the...
Read more >
What is wrong with my autowatch alarm remote? - Fixya
My autowatch remote wont disarm or unlock my door. If I open my door with the key my the alarm sounds then I...
Read more >
mocha.js - Karma Autowatch not working - Stack Overflow
Shouldn't base path be a relative path.. Something like basePath : './' so that it looks for the files in the same directory...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found