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.

No Captured Browser when using with watch

See original GitHub issue

Using the following config:

  grunt.initConfig({
    karma: {
      unit: {
        options: {
          autoWatch: false,
          singleRun: true,
        }
      },
      watch: {
        options: {
          autoWatch: false,
          singleRun: false
        },
        background: true,
      },
      options: {
        configFile: '<%= testFiles.karmaUnit %>',
        browsers: browsers || ['Chrome']
      }
    },

    watch: {
      karma: {
        files: ['karma.conf.js', 'src/main/resources/**/*.js', 'src/test/**/*.js'],
        tasks: ['karma:unit:run']
      },
      options: {
        atBegin: true
      }
    }
  });

  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('testwatch', ['karma:watch:start', 'watch:karma']);

My goal is to have karma start up the background thread and then repeatedly run tests against it when files change. However, when I run ‘testwatch’, it appears the karma:unit:run tries to run before the Karma server really has had a chance to finish starting:

Running "karma:watch:start" (karma) task

Running "watch:karma" (watch) task
Waiting...OK

Running "karma:unit:run" (karma) task
[2014-01-06 12:11:25.495] [DEBUG] config - Loading config /Users/mhughes/ccad/development/firebird/core-plugins/silk/certificate-management/ui/karma.conf.js
No captured browser, open http://localhost:9876/

My browser does start and is connected to the aforementioned address, but it just appears to be a timing issue. If I modify a file after the initial startup, the tests run and are able to connect to the browser. That makes me think that ‘karma⌚start’ does not wait until the browser is truly up and connected.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
jcrbencommented, Mar 8, 2016

I see this warning although my tests seem to be running OK anyway.

0reactions
bierikcommented, Dec 1, 2016

Same problem here… does only occur when autowach is active

Read more comments on GitHub >

github_iconTop Results From Across the Web

Karma not running unit tests due to "No captured browser" ...
I had a face palm moment. karma start needs to be run in the same directory as your karma.conf.js file.
Read more >
"WARN [karma]: No captured browser" message always ...
Expected behaviour Should not see any warnings when starting karma Actual behaviour The following output appears after i run karma start 21 ...
Read more >
Unit testing JavaScript with Karma in 2021. Starting point
Karma was born in the era of AngularJS. This was a significant improvement of existed test tooling on the Web and was one...
Read more >
Configuration File - Karma
The Karma configuration file can be written in JavaScript, CoffeeScript, or TypeScript and is loaded as a regular Node.js module. Unless provided as...
Read more >
Step by Step Unit Testing in Angular
Unit testing is the process of software development where we will test smallest testable units or components of an application. It is also...
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