Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoWatch doesn't work #895

Closed
mgol opened this issue Jan 21, 2014 · 33 comments
Closed

AutoWatch doesn't work #895

mgol opened this issue Jan 21, 2014 · 33 comments

Comments

@mgol
Copy link
Contributor

mgol commented Jan 21, 2014

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.

@vojtajina
Copy link
Contributor

@mzgol Can you run it with --log-level debug and grep the "DEBUG [watcher]" logs? What version of Karma are you using?

@BassT
Copy link

BassT commented Mar 12, 2014

I'm having the same issue:

DEBUG [config]: Loading config /home/sebastian/angular-seed/config/karma.conf.js
DEBUG [plugin]: Loading plugin karma-chrome-launcher.
DEBUG [plugin]: Loading plugin karma-firefox-launcher.
DEBUG [plugin]: Loading plugin karma-jasmine.
INFO [karma]: Karma v0.12.0 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-90772814
DEBUG [launcher]: google-chrome --user-data-dir=/tmp/karma-90772814 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --start-maximized http://localhost:9876/?id=90772814
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-animate.min.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-cookies.min.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-loader.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-loader.min.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-resource.min.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-route.min.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-sanitize.min.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-scenario.js"
DEBUG [watcher]: Excluded file "/home/sebastian/angular-seed/app/lib/angular/angular-touch.min.js"
DEBUG [launcher]: Process Chrome exited with code -1
ERROR [launcher]: Cannot start Chrome
    Can not find the binary google-chrome
    Please set env variable CHROME_BIN
DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-90772814
DEBUG [launcher]: Chrome failed (cannot start). Not restarting.
DEBUG [watcher]: Resolved files:
    /home/sebastian/angular-seed/node_modules/karma-jasmine/lib/jasmine.js
    /home/sebastian/angular-seed/node_modules/karma-jasmine/lib/adapter.js
    /home/sebastian/angular-seed/app/lib/angular/angular.js
    /home/sebastian/angular-seed/app/lib/angular/angular-animate.js
    /home/sebastian/angular-seed/app/lib/angular/angular-cookies.js
    /home/sebastian/angular-seed/app/lib/angular/angular-resource.js
    /home/sebastian/angular-seed/app/lib/angular/angular-route.js
    /home/sebastian/angular-seed/app/lib/angular/angular-sanitize.js
    /home/sebastian/angular-seed/app/lib/angular/angular-touch.js
    /home/sebastian/angular-seed/test/lib/angular/angular-mocks.js
    /home/sebastian/angular-seed/app/js/app.js
    /home/sebastian/angular-seed/app/js/controllers.js
    /home/sebastian/angular-seed/app/js/directives.js
    /home/sebastian/angular-seed/app/js/filters.js
    /home/sebastian/angular-seed/app/js/services.js
    /home/sebastian/angular-seed/test/unit/controllersSpec.js
DEBUG [watcher]: Watching "/home/sebastian/angular-seed/app/lib/angular"
DEBUG [watcher]: Watching "/home/sebastian/angular-seed/test/lib/angular/angular-mocks.js"
DEBUG [watcher]: Watching "/home/sebastian/angular-seed/app/js"
DEBUG [watcher]: Watching "/home/sebastian/angular-seed/test/unit"
DEBUG [watcher]: Add file "/home/sebastian/angular-seed/test/lib/angular/angular-mocks.js" ignored. Already in the list.
DEBUG [watcher]: Add file "/home/sebastian/angular-seed/app/js/controllers.js" ignored. Already in the list.
DEBUG [watcher]: Add file "/home/sebastian/angular-seed/app/js/app.js" ignored. Already in the list.
DEBUG [watcher]: Add file "/home/sebastian/angular-seed/app/js/directives.js" ignored. Already in the list.
DEBUG [watcher]: Add file "/home/sebastian/angular-seed/app/js/filters.js" ignored. Already in the list.
DEBUG [watcher]: Add file "/home/sebastian/angular-seed/app/js/services.js" ignored. Already in the list.
DEBUG [watcher]: Add file "/home/sebastian/angular-seed/test/unit/controllersSpec.js" ignored. Already in the list.
DEBUG [web-server]: upgrade /socket.io/1/websocket/EQeE6Gg8hS2i5d5jVEv9
DEBUG [karma]: A browser has connected on socket EQeE6Gg8hS2i5d5jVEv9
INFO [Chromium 32.0.1700 (Ubuntu)]: Connected on socket EQeE6Gg8hS2i5d5jVEv9 with id 80543638
INFO [watcher]: Changed file "/home/sebastian/angular-seed/test/unit/controllersSpec.js".
DEBUG [karma]: List of files has changed, trying to execute
DEBUG [karma]: All browsers are ready, executing
DEBUG [web-server]: serving: /home/sebastian/angular-seed/node_modules/karma/static/context.html
Chromium 32.0.1700 (Ubuntu) TodoController Test should return notes array with two elements initially and then add one FAILED
    ReferenceError: $controller is not defined
        at null.<anonymous> (/home/sebastian/angular-seed/test/unit/controllersSpec.js:21:18)
        at Object.invoke (/home/sebastian/angular-seed/app/lib/angular/angular.js:3760:17)
        at workFn (/home/sebastian/angular-seed/test/lib/angular/angular-mocks.js:2143:20)
    Error: Declaration Location
        at window.inject.angular.mock.inject (/home/sebastian/angular-seed/test/lib/angular/angular-mocks.js:2128:25)
        at null.<anonymous> (/home/sebastian/angular-seed/test/unit/controllersSpec.js:17:5)
        at /home/sebastian/angular-seed/test/unit/controllersSpec.js:1:1
Chromium 32.0.1700 (Ubuntu): Executed 1 of 1 (1 FAILED) ERROR (6.568 secs / 3.567 secs)

Karma recognizes the file change only once for every file it's watching.

Edit: It works with version 0.10.10

@matteosuppo
Copy link

It happens to me too. Version 0.12.0. It recognize the file change only once. I have a minimal setup:

// banana.js
function banana () {
    return "banana"
}
// test/spec/banana.js
describe('banana', function () {
  it('should return banana', function () {
    expect(banana()).toEqual('banana');
  })
})
// karma.conf.js autogenerated by karma init
// Karma configuration
// Generated on Sat Mar 15 2014 20:19:38 GMT+0100 (CET)

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',
      'test/**/*.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
  });
};
$ karma start --log-level debug
DEBUG [config]: Loading config /home/msuppo/projects/prova/karma.conf.js
DEBUG [plugin]: Loading karma-* from /home/msuppo/projects/prova/node_modules
DEBUG [plugin]: Loading plugin /home/msuppo/projects/prova/node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin /home/msuppo/projects/prova/node_modules/karma-jasmine.
INFO [karma]: Karma v0.12.0 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-33540699
DEBUG [launcher]: google-chrome --user-data-dir=/tmp/karma-33540699 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --start-maximized http://localhost:9876/?id=33540699
DEBUG [watcher]: Excluded file "/home/msuppo/projects/prova/karma.conf.js"
DEBUG [watcher]: Resolved files:
    /home/msuppo/projects/prova/node_modules/karma-jasmine/lib/jasmine.js
    /home/msuppo/projects/prova/node_modules/karma-jasmine/lib/boot.js
    /home/msuppo/projects/prova/node_modules/karma-jasmine/lib/adapter.js
    /home/msuppo/projects/prova/banana.js
    /home/msuppo/projects/prova/test/spec/banana.js
DEBUG [watcher]: Watching "/home/msuppo/projects/prova"
DEBUG [web-server]: serving: /home/msuppo/projects/prova/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /home/msuppo/projects/prova/node_modules/karma/static/karma.js
DEBUG [web-server]: upgrade /socket.io/1/websocket/XjsecSz38EAtAjSzN9Nd
DEBUG [karma]: A browser has connected on socket XjsecSz38EAtAjSzN9Nd
INFO [Chrome 32.0.1700 (Linux)]: Connected on socket XjsecSz38EAtAjSzN9Nd with id 33540699
DEBUG [launcher]: Chrome (id 33540699) captured in 1.528 secs
DEBUG [karma]: All browsers are ready, executing
DEBUG [web-server]: serving: /home/msuppo/projects/prova/node_modules/karma/static/context.html
DEBUG [web-server]: serving (cached): /home/msuppo/projects/prova/node_modules/karma-jasmine/lib/jasmine.js
DEBUG [web-server]: serving (cached): /home/msuppo/projects/prova/node_modules/karma-jasmine/lib/boot.js
DEBUG [web-server]: serving (cached): /home/msuppo/projects/prova/node_modules/karma-jasmine/lib/adapter.js
DEBUG [web-server]: serving (cached): /home/msuppo/projects/prova/banana.js
DEBUG [web-server]: serving (cached): /home/msuppo/projects/prova/test/spec/banana.js
Chrome 32.0.1700 (Linux): Executed 1 of 1 SUCCESS (0.006 secs / 0.001 secs)
INFO [watcher]: Changed file "/home/msuppo/projects/prova/banana.js".
DEBUG [karma]: List of files has changed, trying to execute
DEBUG [karma]: All browsers are ready, executing
DEBUG [web-server]: serving: /home/msuppo/projects/prova/node_modules/karma/static/context.html
Chrome 32.0.1700 (Linux): Executed 1 of 1 SUCCESS (0.007 secs / 0 secs)

@matteosuppo
Copy link

Here's what breaking it, imho:
e88fbc2

If I set usePolling to true it works.

Now I just have to understand why it doesn't work with usePolling=false;

@vojtajina
Copy link
Contributor

I think I'm gonna cry... Seriously. Can some OS finally make the file watching to work?

Sounds like we should enable polling again, on all platforms (currently it is disabled on Mac where fsevents are buggy as well). I thought this worked on Linux ;-) I mean, I tested it a lot...

@matteosuppo @mzgol @BassT what version of Node are you guys on?
Can you please try latest 0.10?

In the meantime, set usePolling: true as @matteosuppo did.

@matteosuppo
Copy link

I'm using the latest version

node -v
v0.10.26

By the way it seems like Sublime Text could be the culprit, for me. If it's shut down, the file changes are detected. Maybe it is blocking them somehow?

@matteosuppo
Copy link

I digged up this: http://stackoverflow.com/questions/20634684/what-is-sublime-text-doing-when-i-save-a-file

The problem for me was solved by changing "atomic_save": false in the settings. I don't know if it's worth of a FAQ

@vojtajina
Copy link
Contributor

Can other people having this issue try changing the Sublime settings?

It's still weird, even if Sublime does atomic_save: true, Karma should notice, it might just be seen as "remove" + "add" (instead of "change").

@BassT
Copy link

BassT commented Mar 18, 2014

node -v
v0.10.26

karma 0.10.10 works fine for me. I'm gonna try 0.12 asap with changed sublime settings, though I recall that it wasn't working when I saved files with eclipse either.

@davidlgj
Copy link

It starts picking up changes again after setting atomic_save: false in sublime. Nice to have a workaround at least :-)

@vojtajina
Copy link
Contributor

Wait, @BassT are you saying it works with karma 0.10.x but not with 0.12? Then, it's probably the usePolling config, that's the only thing that has changed, AFAIK. You can try to set it to true (polling, can give you high CPU consumption if you watch many files) / false (OS events, buggy, but cheap; long term THE solution).

@vojtajina
Copy link
Contributor

If anybody interested in this, take a look at #974

@andyczerwonka
Copy link

Yup, atomic_save": false does the trick.

@pallogu
Copy link

pallogu commented May 2, 2014

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

@owickstrom
Copy link

"atomic_save": false worked for me as well, using Sublime 3 and Ubuntu 12.04.

@oehm-smith
Copy link

Me too. Not using Sublime.

Node: v0.10.25
Karma: v0.12.16

usePolling: true fixes it.

I have a possibly different setup where I'm running off a NAS and run node on unix (which obviously mounts the nas drive) but run WebStorm through Windows (ditto).

@mokkabonna
Copy link

Same for me sublime 3, usePolling:true restores previous behaviour, but using atomic_save: false in sublime instead for performance.

@dduft
Copy link

dduft commented Jun 19, 2014

"atomic_save": false solved the autoWatch-issue but the test-runs where inconsistent. When I change my spec and saved the code, it executes correct. Saving once more without any changes runs test before change. Saving several times without changes runs test before and after change in turn?!?
Deleting "atomic_save": false and usePolling: true heals everything.

@RaimundSchramm
Copy link

Same for me still using sublime 2 where there seems to be no atomic_save: .

Updating karma config to with usePolling: true seems to solve autoWatch-once-issue.

zhang-ning added a commit to zhang-ning/RiverJS that referenced this issue Jul 7, 2014
@ghost
Copy link

ghost commented Oct 28, 2014

I'm having the same issue. I am seeing inconsistent behavior too -- some runs will re-run tests when I touch files in src/, other runs do not, with no changes to config.

As of most recent runs, setting usePolling: true is working for changes made to source code, but not to tests. The former is under src/, the latter under test/ .

I'm sorry to complain, as Karma is extremely useful when it works, but just to say, I have lost many days over the last year when new installs of Karma have one issue or another that I cannot track down. There are so many karma-* modules that depend on whichever version that this makes it difficult to try rolling back the version. It would be nice if it didn't break so frequently. At the moment, I can work around by killing and restarting Karma every time I add/modify a test, but this is a real pain.

I'm on OS X 10.9.5.

packages.json

 ...
 "devDependencies": {
 "grunt": "^0.4.4",
 "grunt-contrib-jshint": "^0.9.2",
 "grunt-contrib-nodeunit": "~0.2.0",
 "grunt-contrib-uglify": "^0.4.0",
 "grunt-contrib-concat": "^0.3.0",
 "grunt-qunit-amd": "^0.1.1",
 "karma": "^0.12.24",
 "mocha": "^2.0.1",
 "karma-mocha": "^0.1.9",
 "chai": "^1.9.2",
 "karma-chai": "^0.1.0",
 "sinon": "^1.11.1",
 "karma-sinon": "^1.0.3",
 "karma-requirejs": "^0.2.2",
 "karma-chrome-launcher": "^0.1.5"
},
...

karma.conf.js

module.exports = function(config) {
config.set({
  basePath: '../..',
  frameworks: ['mocha', 'requirejs'],
  client: {
    mocha: {
        ui: 'bdd'
    }
  },
  files: [
  // {pattern: 'libs/**/*.js', included: false},
  {pattern: 'libs/pubsub/pubsub.js', included: false},
  {pattern: 'src/**/*.js', included: false},
  {pattern: 'test/mocha/mocha.js', included: false},
  {pattern: 'test/should/should.js', included: false},
  {pattern: 'test/**/*Spec.js', included: false},

  'test/karma/test-main.js'
  ],
exclude: [
  'src/main.js'
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
port: 9876,
colors: true,
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_WARN,
autoWatch: true,
usePolling: 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
});

};

@awerlang
Copy link

I discovered something to do with WebStorm today.
As of karma 0.12.25, using WebStorm 9 (safe-write=false), this ain't working, even usePolling set to true. WebStorm there's a plugin to run karma, and in this mode it doesn't work.

Running with "karma start" it works, usePolling = (false|true).

@JetFault
Copy link
Contributor

Having the same issue, on ubuntu 14.10. Using vim, tried both usePolling false and true. Even tried making a new file with cat. Still nothing getting rerun.

karma 0.12.24

EDIT: I figured it out.

In karma.conf.js my files were:

files: [
  'src/{app,componets}/**/*.js'
]

Which when looking at watch logs came up as this:

DEBUG [watcher]: Watching "/home/jerry/code/blah/src/{app,components}"

Switching my files to src/app/**/*.js and src/components/**/*.js fixed it.

Not sure if this is intended behaviour though

@mgol
Copy link
Contributor Author

mgol commented Nov 21, 2014

@JetFault

Switching my files to src/app/**/*.js and src/components/**/*.js fixed it.

This! I confirm it on my side; I had patterns like:

'test/unit/{data,mocks-inlined}/*.json',

Switching it to:

'test/unit/data/*.json',
'test/unit/mocks-inlined/*.json',

makes the watcher work. So since the very beginning this issue for me had nothing to do with usePolling etc., just with the way of specifying patterns.

@vojtajina Why is this not glob-compatible? Is this intended?

@maksimr
Copy link
Contributor

maksimr commented Nov 21, 2014

@mzgol it's because we watch only directory and in watcher.js we doesn't use glob library for getting directory.
Seems we should make more robust way to define root directory.

@mzgol patterns source of your problem?

@mgol
Copy link
Contributor Author

mgol commented Nov 25, 2014

@maksimr Yes, this was my issue. I didn't even think that it may be a different pattern format issue.

So it seems this issue should be closed unless you want to add support for groups to watcher.js. Other issues, with polling etc. are different to the issue I had and reported.

@JetFault
Copy link
Contributor

@mzgol This was added in: #1251

@maksimr
Copy link
Contributor

maksimr commented Nov 25, 2014

Fix in canary branch

@codazzo
Copy link

codazzo commented Oct 29, 2015

If you're still having this problem, keep in mind that depending on the size of your project and the way you load your dependencies, karma might actually exceed the open files limit. See http://docs.basho.com/riak/latest/ops/tuning/open-files-limit for instructions on how to increase it. This is what worked for me.

@rryter
Copy link

rryter commented Aug 2, 2016

I can confirm disabling 'safe write' in Intellij solves the problem. thx @pallogu

@dougrchamberlain
Copy link

@maksimr mentions this is fixed in canary branch, however. I still experience the issue. Here is my workaround. Please let me know if this resolves the issue for anyone else. I've only tested this on Chrome, I'm sure similar approaches would work for the other browsers. Once you enter karma start and the browser launches, enable dev tools, check disable cache from the network tab. With the cache completely disabled, chrome no longer gets a cached version of the spec files.

@ramadanko-zz
Copy link

ramadanko-zz commented Mar 31, 2017

Hi guys, i had the same issue yesterday and none of these solutions worked for me, but i set singleRun in karma.conf.js to true which means it will run once and exit, then i watch the files with gulp.watch and on change i run karma from there, and i prefer this solution even if there is no problem with karma, because we have to check for UT while development too in one console.
`
var Server = require('karma').Server;
gulp.task('karma', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js'
}, done).start();
});

gulp.task('watch', function () {
gulp.watch(['./client//*.js', './client//*.html'], ['inject', 'reload', 'karma']);
});
`

@sbrady
Copy link

sbrady commented Apr 19, 2017

Although this is RE: intellij.
Adding the following line to /etc/sysctl.conf
fs.inotify.max_user_watches = 524288
Then
sudo sysctl -p --system

fixed it on my linux box
https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit

@nazandrey
Copy link

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 (paulmillr/chokidar#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 :)

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

No branches or pull requests