Karma: "WARN [karma]: No captured browser" message always appears

Created on 21 Sep 2016  路  23Comments  路  Source: karma-runner/karma

Expected behaviour

Should not see any warnings when starting karma

Actual behaviour

The following output appears after i run karma start

21 09 2016 18:28:21.960:WARN [karma]: No captured browser, open http://localhost:9876/
21 09 2016 18:28:21.970:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
21 09 2016 18:28:21.970:INFO [launcher]: Launching browser Chrome with unlimited concurrency
21 09 2016 18:28:21.992:INFO [launcher]: Starting browser Chrome
21 09 2016 18:28:22.881:INFO [Chrome 53.0.2785 (Linux 0.0.0)]: Connected on socket /#OLx2oK-yFrqokDyYAAAA with id 52089739

Environment Details

  • Karma version (output of karma --version): 1.3.0
  • Relevant part of your karma.config.js file:
// Karma configuration
// Generated on Wed Sep 21 2016 18:16:01 GMT+0100 (BST)

module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine'],
    files: [
      '*.js'
    ],
    exclude: [
    ],
    preprocessors: {
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
    concurrency: Infinity
  })
}

Steps to reproduce the behaviour

  1. create a new project, set up package.json with :

    "devDependencies": {
     "jasmine-core": "^2.5.2",
     "karma": "^1.3.0",
     "karma-chrome-launcher": "^2.0.0",
     "karma-jasmine": "^1.0.2"
    }
    
  2. use the above karma.conf.js
  3. create a dummy js file so karma has something to load (eg. test.js)
  4. run karma start, and you should see a warning
investigation

Most helpful comment

Hey guys,
Any updates on this issue?

All 23 comments

I get the same behavior with a clean, out of the box project created with 'ng new site-name', then changing the brosers to ['PhantomJS']
I get the the warning, then it runs the tests, they pass, but the command doesn't exist.
karma version 1.3.0

I have exactly the same problem, trying with PhantomJS.

Amy, I followed the directions straight from Angular2 for testing and those are the only ones that worked for me. nothing else. Watch out for the '/base' directory in the karma config file. That is needed for karma even though there is no '/base' directory in your project.
Check it out: https://angular.io/docs/ts/latest/guide/testing.html
it looks like a lot but it's basically getting karma installed properly.

Thanks @innergap. For the time being, as it is a very small module which I'm implementing, a sort of proof of concept, I just disabled karma and I'm running the tests manually.

I'll give it a try later and return with some feedback on how it goes.

Wouldn't logLevel: config.LOG_INFO suggest it is supposed to log any info logs or higher, which would include warnings since warnings are at a higher level?

Here are the docs on logLevel:

Type: Constant
Default: config.LOG_INFO
CLI: --log-level debug
Possible values:
config.LOG_DISABLE
config.LOG_ERROR
config.LOG_WARN
config.LOG_INFO
config.LOG_DEBUG
Description: Level of logging.

See logLevel here.

Was anyone able to make any progress on this issue? I recently started seeing this warning when migrating the build of an existing React application from Gulp to Webpack 2. I'm running the same versions of jasmine-core, karma, and karma-chrome-launcher, but version ^1.1.0 of karma-jasmine.

Came here to duplicate @chazzlabs comment. Searching for a solution that works long term.

same here !!!

will be there any fix soon?

Maybe, it helps
mime: { 'text/x-typescript': ['ts','tsx'] },

I have the same issue.
I install karma using instruction from the official site. During the installation I chose to use Google Chrome browser for testing - karma init
After run karma start - I only get the warn. All tests finish correct.

03 07 2017 15:22:46.108:WARN [karma]: No captured browser, open http://localhost:9876/
03 07 2017 15:22:46.241:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
03 07 2017 15:22:46.243:INFO [launcher]: Launching browser Chrome with unlimited concurrency
03 07 2017 15:22:46.289:INFO [launcher]: Starting browser Chrome
03 07 2017 15:22:59.253:INFO [Chrome 59.0.3071 (Mac OS X 10.12.5)]: Connected on socket Pm5Y0RVF7pKA-ZqaAAAA with id 16979434

But when I use karma run, get the error:
03 07 2017 15:34:45.867:ERROR [runner]: There is no server listening on port 9876
How can I fix this error?

I've had this crop up a few times.

  • Try commenting out or renaming all your spec files so they don't run.
  • Retry Karma. Browser should start, connect and show you have no tests
  • Then start uncommenting/unrenaming your spec files one by one until you find the one that's broken

Horrible but only way I've managed to get things back up and running again.

PS: I have a LOT of spec files, so without an error to tell me where to look it was hard to know. Last time this happened to me I started my PC and it was just broken, I had a ton of spec files changed and no clue where to look. In this case the problem was caused by Webstorm adding:

import { describe } from "selenium-webdriver/testing";

Hey guys,
Any updates on this issue?

I was facing the same issue and i resolved it by killing all the chrome instances from Task Manager. It seems that there were 'n' number of test runners running. When you close the karma test runner without stopping the server, it's instance is still alive.

So press 'alt + ctrl + delete', kill all sessions/instances of chrome and restart Karma.

It works!

I also had this problem when using a proxy. If you are behind a proxy and have set HTTP_PROXY and HTTPS_PROXY be sure to also include the following addresses to NO_PROXY

NO_PROXY 127.0.0.1,0.0.0.0,localhost

Otherwise your test will try to use the proxy connecting to the browser and will fail to do so.

Still open since 2016, any updates on this issue?

I still get this same error, is there any update? The workaround is to open that URL in my Chrome, then Karma starts running my tests correctly everytime I modify my files. But the ideal would be not to have to open any Chrome tab as that's why I'm using Chrome Headless on the first place.

Having the same issue. Karma opens the chrome window with an URL that looks like a file url (like _http://c/Users/.../Documents/...:9876/?id=24594662_) instead of _localhost_. Seems like that is the problem why headless chrome is waiting forever to connect. Removing the _headless_-flag from the config and manually setting the url to _localhost:986..._ solves the issue for me as well. Just as @dwilches suggested as a workaround.

Still having this issue. Any updates??

The original post describes karma working as intended. The config lists singleRun: false,, meaning that the server expects to say up and not "launch-browser, test, exit". Karma prints the subject message so you know what link to open for debugging. I suppose it could be 'info'.

I guess this is not really the problem folks are complaining about, but it is the one that is described and thus that is all I can go on.

For me the problem was in CHROME_BIN path containing tilda ~ instead of absolute path to chrome binary. This worked for me on a fresh project created with npx ng new:
CHROME_BIN=/home/user/.../bin/chromium npx ng test

3.5 years and still no solution?

3.5 years and still no solution?

karma has worked fine for millions of tests over those 3.5 years. So perhaps there never was a problem here?

The "No captured browser" means karma can't automatically test because it does not have a browser to launch tests in. I speculated on the cause, a deliberate config issue, above. Without further information there is nothing to do here.

I suggest opening a new issue with a complete description from a recent karma version and the output of --logLevel=DEBUG.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wellyshen picture wellyshen  路  4Comments

donaldpipowitch picture donaldpipowitch  路  3Comments

schippie picture schippie  路  5Comments

ORESoftware picture ORESoftware  路  4Comments

jhildenbiddle picture jhildenbiddle  路  4Comments