karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

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

Closed janeklb closed 4 years ago

janeklb commented 8 years ago

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 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
innergap commented 8 years ago

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

amypellegrini commented 8 years ago

I have exactly the same problem, trying with PhantomJS.

innergap commented 8 years ago

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.

amypellegrini commented 8 years ago

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.

wesleycho commented 7 years ago

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:

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.

chazzlabs commented 7 years ago

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.

weo3dev commented 7 years ago

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

nudelx commented 7 years ago

same here !!!

robert197 commented 7 years ago

will be there any fix soon?

JuliaAlaeva commented 7 years ago

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

volosovich commented 7 years ago

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?

ChrisGibb commented 7 years ago

I've had this crop up a few times.

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";
aleksspeaker commented 6 years ago

Hey guys, Any updates on this issue?

rahulswimmer commented 6 years ago

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!

relief-melone commented 5 years ago

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.

Famin42 commented 5 years ago

Still open since 2016, any updates on this issue?

dwilches commented 5 years ago

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.

eweren commented 5 years ago

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.

praxder commented 4 years ago

Still having this issue. Any updates??

johnjbarton commented 4 years ago

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.

Radivarig commented 4 years ago

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

Danieliverant commented 4 years ago

3.5 years and still no solution?

johnjbarton commented 4 years ago

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.

clintSanch commented 3 months ago

its the year 2024 and the issue/error still hitting me hard! any sln?