Giter Site home page Giter Site logo

karma-chrome-launcher's Introduction

karma-chrome-launcher

js-standard-style npm version npm downloads

Build Status Dependency Status devDependency Status

Launcher for Google Chrome, Google Chrome Canary and Google Chromium.

Installation

The easiest way is to keep karma-chrome-launcher as a devDependency in your package.json, by running

$ npm i -D karma-chrome-launcher

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['Chrome', 'Chrome_without_security'], // You may use 'ChromeCanary', 'Chromium' or any other supported browser

    // you can define custom flags
    customLaunchers: {
      Chrome_without_security: {
        base: 'Chrome',
        flags: ['--disable-web-security', '--disable-site-isolation-trials']
      }
    }
  })
}

The --user-data-dir is set to a temporary directory but can be overridden on a custom launcher as shown below. One reason to do this is to have a permanent Chrome user data directory inside the project directory to be able to install plugins there (e.g. JetBrains IDE Support plugin).

customLaunchers: {
  Chrome_with_debugging: {
    base: 'Chrome',
    chromeDataDir: path.resolve(__dirname, '.chrome')
  }
}

You can pass list of browsers as a CLI argument too:

$ karma start --browsers Chrome,Chrome_without_security

Headless Chromium with Puppeteer

The Chrome DevTools team created Puppeteer - it will automatically install Chromium for all platforms and contains everything you need to run it from within your CI.

Available Browsers

Note: Headless mode requires a browser version >= 59

  • Chrome (CHROME_BIN)
  • ChromeHeadless (CHROME_BIN)
  • Chromium (CHROMIUM_BIN)
  • ChromiumHeadless (CHROMIUM_BIN)
  • ChromeCanary (CHROME_CANARY_BIN)
  • ChromeCanaryHeadless (CHROME_CANARY_BIN)
  • Dartium (DARTIUM_BIN)

Usage

$ npm i -D puppeteer karma-chrome-launcher
// karma.conf.js
process.env.CHROME_BIN = require('puppeteer').executablePath()

module.exports = function(config) {
  config.set({
    browsers: ['ChromeHeadless']
  })
}

For more information on Karma see the homepage.

karma-chrome-launcher's People

Contributors

23x23x avatar abbotto avatar alias-mac avatar asemy avatar aymericbeaumet avatar cexbrayat avatar dependabot[bot] avatar dignifiedquire avatar dpogue avatar fidge123 avatar florian-r avatar frsimond avatar gkostov avatar greenkeeperio-bot avatar haifengkao avatar ishitatsuyuki avatar jeffbcross avatar johnjbarton avatar krinkle avatar maieutiquer avatar mgol avatar mvuksano avatar nimi avatar rgant avatar rogeriopvl avatar sbley avatar semantic-release-bot avatar sukrosono avatar vojtajina avatar zzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

karma-chrome-launcher's Issues

karma crashes when chrome is already running

When launching the karma test with chrome already running, three karma tabs open, connect, lose the connection again and then karma crashes.
When you close two of the tabs fast enough, everything works.

INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at C:\Users\[...]\AppData\Local\Temp\karma-40710999
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\[...]\AppData\Local\Temp\karma-40710999 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate ht
tp://localhost:9876/?id=40710999
DEBUG [framework.browserify]: building bundle
DEBUG [framework.browserify]: adding [...] to bundle
DEBUG [launcher]: Process Chrome exited with code 0
ERROR [launcher]: Cannot start Chrome

DEBUG [temp-dir]: Cleaning temp dir C:\Users\[...]\AppData\Local\Temp\karma-40710999
INFO [launcher]: Trying to start Chrome again (1/2).
DEBUG [launcher]: Restarting Chrome
DEBUG [temp-dir]: Creating temp dir at C:\Users\[...]\AppData\Local\Temp\karma-40710999
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\[...]\AppData\Local\Temp\karma-40710999 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate ht
tp://localhost:9876/?id=40710999
DEBUG [launcher]: Process Chrome exited with code 0
ERROR [launcher]: Cannot start Chrome

DEBUG [temp-dir]: Cleaning temp dir C:\Users\[...]\AppData\Local\Temp\karma-40710999
INFO [launcher]: Trying to start Chrome again (2/2).
DEBUG [launcher]: Restarting Chrome
DEBUG [temp-dir]: Creating temp dir at C:\Users\[...]\AppData\Local\Temp\karma-40710999
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\[...]\AppData\Local\Temp\karma-40710999 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate ht
tp://localhost:9876/?id=40710999
DEBUG [framework.browserify]: bundling
DEBUG [launcher]: Process Chrome exited with code 0
ERROR [launcher]: Cannot start Chrome

DEBUG [temp-dir]: Cleaning temp dir C:\Users\[...]\AppData\Local\Temp\karma-40710999
DEBUG [web-server]: serving: D:\[...]\node_modules\karma\static/client.html
DEBUG [web-server]: serving (cached): D:\[...]\node_modules\karma\static/client.html
ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.
DEBUG [web-server]: serving (cached): D:\[...]\node_modules\karma\static/client.html
DEBUG [web-server]: serving: D:\[...]\node_modules\karma\static/karma.js
DEBUG [web-server]: serving (cached): D:\[...]\node_modules\karma\static/karma.js
DEBUG [web-server]: serving (cached): D:\[...]\node_modules\karma\static/karma.js
[...]
DEBUG [web-server]: upgrade /socket.io/1/websocket/hZrbHj-2BzuPr_YNkUmW
DEBUG [karma]: A browser has connected on socket hZrbHj-2BzuPr_YNkUmW
DEBUG [web-server]: upgrade /socket.io/1/websocket/9Nh06gkCmfm7Ag4dkUmX
DEBUG [karma]: A browser has connected on socket 9Nh06gkCmfm7Ag4dkUmX
DEBUG [web-server]: upgrade /socket.io/1/websocket/JFZ5G4UQX3ciOHOnkUmY
DEBUG [karma]: A browser has connected on socket JFZ5G4UQX3ciOHOnkUmY
INFO [Chrome 39.0.2171 (Windows 8.1)]: Connected on socket hZrbHj-2BzuPr_YNkUmW with id 40710999
DEBUG [launcher]: Chrome (id 40710999) captured in 4.242 secs
DEBUG [Chrome 39.0.2171 (Windows 8.1)]: New connection 9Nh06gkCmfm7Ag4dkUmX (already have hZrbHj-2BzuPr_YNkUmW)
DEBUG [Chrome 39.0.2171 (Windows 8.1)]: New connection JFZ5G4UQX3ciOHOnkUmY (already have hZrbHj-2BzuPr_YNkUmW, 9Nh06gkCmfm7Ag4dkUmX)
DEBUG [watcher]: Add file "D:/fab3d-lowfab/testClient/stlImportTest.coffee" ignored. Already in the list.
WARN [Chrome 39.0.2171 (Windows 8.1)]: Disconnected (1 times), because no message in 10000 ms.
ERROR [karma]: [TypeError: Cannot call method 'map' of undefined]
TypeError: Cannot call method 'map' of undefined
  at [object Object]._render (D:\[...]\node_modules\karma\lib\reporters\progress.js:56:27)
  at [object Object]._refresh (D:\[...]\node_modules\karma\lib\reporters\progress.js:60:34)
  at [object Object].onBrowserComplete (D:\[...]\node_modules\karma\lib\reporters\progress.js:19:21)
  at [object Object].<anonymous> (D:\[...]\node_modules\karma\lib\events.js:15:22)
  at [object Object].emit (events.js:117:20)
  at [object Object]._onTimeout (D:\[...]\node_modules\karma\lib\browser.js:53:15)
  at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

DEBUG [launcher]: Disconnecting all browsers
DEBUG [framework.browserify]: cleaning up

Name of Chrome binary, Linux

Hi!

The name of the Chrome binary (at least on Arch Linux) has changed from google-chrome to google-chrome-stable. Would it be possible to support both ways out of the box? I took a quick look at the source file, but I couldn't see where the actual load took place

What is karma-chrome-launcher?

As per the words, I think this will invoke an installed Chrome application from my environment, correct?
If that is the case, one can conclude that it's required to have Chrome installed on the operating system before being able to use this package. Am I correct so far?

My end problem is that my work environment is a CentOS without GUI (only CLI). How do people install Chrome on such environments? The closest I've got was yum install google-chrome-stable (after enabling google-chrome repository) and getting a Requires: libstdc++.so.6(GLIBCXX_3.4.14)(64bit). I've lost a fair amount of time dealing with it and I would just like a confirmation that indeed these things are prerequisite to start using Karma with Chrome.

Can't open browsers installed in user's Application directory on OSX

Reposted by request of @dignifiedquire
I see in the launcher files for Chrome and Firefox there are some lookups for both Windows and Linux to get the correct browser. However, with OSX, it's always being hardcoded to /Applications.
While I know this can be worked around by setting the CHROME_BIN and FIREFOX_BIN to the users Application directory, I think it's a common enough scenario that I imagine the launchers should at least attempt to see if it exists in ~/Applications first.

(As a side note, the files seem a little inconsistent in how they're looking up the different browsers, Opera doesn't appear to try to look up for any of the systems).

Is this something you guys would think about fixing?

Chrome does not start on Jenkins with Chrome 38.0.2125.104 m

I have setup Jenkins to use karma for unit testing for long. It works fine until Chrome got updated to the latest. Like mentioned here http://stackoverflow.com/questions/26472457/jenkins-karma-chrome-not-working-after-last-auto-update-of-chrome.

Here is the debug log I captured.

c:\jenkins\workspace\UnitTest>karma start --reporters junit,html,coverage,progress --browsers Chrome --single-run --log-level debug --no-colors   || exit 0 
DEBUG [config]: Loading config c:\jenkins\workspace\UnitTest\test\ui-unit\karma.conf.js
DEBUG [config]: autoWatch set to false, because of singleRun
DEBUG [plugin]: Loading karma-* from c:\jenkins\workspace\UnitTest\node_modules
DEBUG [plugin]: Loading plugin c:\jenkins\workspace\UnitTest\node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin c:\jenkins\workspace\UnitTest\node_modules/karma-coverage.
DEBUG [plugin]: Loading plugin c:\jenkins\workspace\UnitTest\node_modules/karma-firefox-launcher.
DEBUG [plugin]: Loading plugin c:\jenkins\workspace\UnitTest\node_modules/karma-html-reporter.
DEBUG [plugin]: Loading plugin c:\jenkins\workspace\UnitTest\node_modules/karma-jasmine.
DEBUG [plugin]: Loading plugin c:\jenkins\workspace\UnitTest\node_modules/karma-junit-reporter.
DEBUG [plugin]: Loading plugin c:\jenkins\workspace\UnitTest\node_modules/karma-osx-reporter.
INFO [karma]: Karma v0.12.24 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate http://localhost:9876/?id=28077601
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
DEBUG [launcher]: Process Chrome exited with code 0
DEBUG [temp-dir]: Cleaning temp dir C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601
INFO [launcher]: Trying to start Chrome again (1/2).
DEBUG [launcher]: Restarting Chrome
DEBUG [temp-dir]: Creating temp dir at C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate http://localhost:9876/?id=28077601
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
DEBUG [launcher]: Process Chrome exited with code 0
DEBUG [temp-dir]: Cleaning temp dir C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601
INFO [launcher]: Trying to start Chrome again (2/2).
DEBUG [launcher]: Restarting Chrome
DEBUG [temp-dir]: Creating temp dir at C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601
DEBUG [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate http://localhost:9876/?id=28077601
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
DEBUG [launcher]: Process Chrome exited with code 0
DEBUG [temp-dir]: Cleaning temp dir C:\Users\ADMINI~1\AppData\Local\Temp\karma-28077601
ERROR [launcher]: Chrome failed 2 times (timeout). Giving up.
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers

Tests don't run in Chrome Without Startup Window

I have this in my karma.conf.js since I don't want the browser popup in my face:

module.exports = function(config){
  config.set({

    basePath: '../',
    autoWatch: true,
    frameworks: ['jasmine'],
    browsers: ['chrome_without_startup_window'],

    customLaunchers: {
      chrome_without_startup_window: {
        base: 'Chrome',
        flags: ['--no-startup-window']
      }
    },
   ... ... ...
  });
};

Then when I start karma

[dmoore (master)]$ gulp unit
[gulp] Using gulpfile /Users/dmoore/projects/tutorials/angular-phonecat2/gulpfile.js
[gulp] Starting 'unit'...
[gulp] Starting Karma server...
WARN [karma]: Port 9876 in use
WARN [karma]: Port 9877 in use
WARN [karma]: Port 9878 in use
INFO [karma]: Karma v0.10.9 server started at http://localhost:9879/
INFO [launcher]: Starting browser Chrome

The browser window no longer opens, but the test don't execute either? What am I missing here, please?

Launch in background

I know this is out of scope but out of interest...

I didn't find a way to specify opening the browser in the background. Stealing focus from the terminal window is just unwanted, for most cases, I guess.

I think it should be default.

There's a flags thing. I read the manual. There's nothing. Perhaps a trick with --display?

It points to this and this, which also don't seem to have what is required. Perhaps something with --class?

This is relevant for all the other "real" browser launchers, as well.

Error during loading "karma-chrome-launcher" plugin: Cannot find module 'fs-access'

I am getting these errors when I start karma runner.

09 10 2015 19:35:54.336:WARN [plugin]: Error during loading "karma-chrome-launcher" plugin:
  Cannot find module 'fs-access'
09 10 2015 19:35:54.348:WARN [plugin]: Error during loading "karma-babel-preprocessor" plugin:
  Cannot find module 'babel-core'
Hash: 8344a6c0a9b3c44a5636
Version: webpack 1.12.2
Time: 59ms

ERROR in Cannot find module 'babel-core'

All the packages above are already installed. I don't know what gives...

Here is my config file:

var webpackConfig = require(__dirname + '/webpack/test.config');
module.exports = function(config) {
  config.set({
    basePath: '../assets/',
    frameworks: ['chai', 'chai-as-promised'],
    files: [
      'karma.tests.js'
    ],
    preprocessors: {
      'karma.tests.js': ['webpack']
    },
    webpack: {
      resolve: webpackConfig.resolve,
      module: webpackConfig.module,
      // target: 'node'
    },
    webpackMiddleware: {
      // stats: {
      //   colors: true
      // },
      noInfo: true
    },
    reporters: ['dots'],
    plugins: [
      'karma-webpack',
      'karma-chai-plugins',
      'karma-chrome-launcher',
      'karma-babel-preprocessor',
      'karma-phantomjs-launcher',
      'karma-sourcemap-loader'
    ],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: [
      'PhantomJS',
      // 'PhantomJS_custom',
      // 'Chrome'
    ],
    singleRun: true,
    customLaunchers: {
      'PhantomJS_custom': {
        base: 'PhantomJS',
        options: {
          windowName: 'my-window',
          settings: {
            webSecurityEnabled: false
          }
        },
        flags: ['--load-images=true'],
        //debug: true
      }
    }

  });
}

Better detection of path to google-chrome on darwin.

I use brew cask (http://caskroom.io/) to install google-chrome and so my Google Crome.app is actually a soft link that lives in my user's Applications (~/Applications) directory, not the global /Applications directory. It seems like the path to chrome on darwin is currently hard-coded to /Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary.

I would like to suggest the karma-chrome-launcher use lsregister to find an installation of Google Chrome (as described in http://apple.stackexchange.com/questions/95837/find-google-chrome-installation-directory-on-mac-using-terminal and http://stackoverflow.com/questions/5860517/path-to-application-without-opening-it) or simply look in the user's ~/Applications directory first, then fall back to the global /Applications path.

I realize I can set the path using the CHROME_BIN environmental variable, but it would be nice if karma could fall back or better detect the "default" path to Chrome without having to set it explicitly using the environment variable.

I am happy to do this work, but wanted to get feedback on the idea first to see if it was something that would even be accepted.

"No binary for Chrome browser on your platform"

Hey guys!

I just made the upgrade to 2.0.0, and now I receive an error when running...

ERROR [launcher]: No binary for Chrome browser on your platform.
  Please, set "CHROME_BIN" env variable.

The solution is pretty clear, I just run an $ export CHROME_BIN=chromium and it runs fine.

My question is, why did I not have to export a var in the previous release? Is there a way around this without setting a specific executable? I just foresee having ci issues down the road, or possibly cross platform issues with people pulling the project, but maybe I'm not looking at this correctly.

0.1.11 Breaks Chrome launching on OS X

Looks like this was introduced by d442548

From what I can tell fs.realpathSync throws an error if the path isn't found, but the code expects it to return true/false. The error prevents the defaultPath param from getting registered and Chrome doesn't launch.

WARN [plugin]: Error during loading "/Users/joechrz/projects/fire-engine/node_modules/karma-chrome-launcher" plugin:
  ENOENT, no such file or directory '/Users/joechrz/Applications/Google Chrome.app'
INFO [framework.browserify]: registering rebuild (autoWatch=true)
[17:10:37] Starting 'serve'...
fire-engine.js was browserified: 0.701s
WARN [karma]: Port 9876 in use
[17:10:37] Finished 'serve' after 1.5 ms
INFO [karma]: Karma v0.12.31 server started at http://localhost:9877/
WARN [launcher]: Can not load "Chrome", it is not registered!
  Perhaps you are missing some plugin?

Use source maps

Can we launch Chrome with source maps enabled so stack traces reference orignal line numbers when test are browserified?

Seems like there should be a CLI flag but I haven't found it yet. Also seems like the setting is stored somewhere in the user-data-dir. There might be a configuration file we can copy into the temp dir.

Chrome (52) have not captured, killing

As of an update to Chrome 52 our CI buildserver is having issues running our karma specs.

below is a log:

INFO [karma]: �[39mKarma v1.1.1 server started at http://localhost:9876/
INFO [launcher]: �[39mLaunching browser Chrome with unlimited concurrency
INFO [launcher]: �[39mStarting browser Chrome
WARN [launcher]: �[39mChrome have not captured in 60000 ms, killing.
INFO [launcher]: �[39mTrying to start Chrome again (1/2).
WARN [launcher]: �[39mChrome have not captured in 60000 ms, killing.
INFO [launcher]: �[39mTrying to start Chrome again (2/2).
WARN [launcher]: �[39mChrome have not captured in 60000 ms, killing.
ERROR [launcher]: �[39mChrome failed 2 times (timeout). Giving up.

Details:
Karma 1.1.1
Karma-Chrome-Launcher 1.0.1
Chrome 52

Kind Regards

Utilizing Filesystem API

Having a bit of trouble getting the filesystem api to work with the chrome launcher. Any suggestions for configuring this?
Thanks!

Chrome does not rerun tests when minified

When I run my tests in automatic rerun mode (--no-single-run --auto-watch), the Chrome tests will not start rerunning when Chrome is minified. Not sure whether this makes a difference, but I am using Windows.

Firefox and IE don't have this problem.

Chrome launching without plugins

I noticed that the when Karma launches Chrome it do so without plugins. I am using Webstorm as my IDE, and it has some wonderful debugging tools. However, I need the JetBrains Chrome debug plugin enabled for it to work. Is there some way to have karma launch Chrome WITH plugins enabled?

No README data

When I npm install this package I get the error:

npm WARN package.json [email protected] No README data

Normally I only see that when a package doesn't have a README.md file, but this one has one, so I'm not sure what the problem is. You'll notice that it doesn't have any README.md data on the package listing on npmjs.org. But I'd really like to get rid of this warning as it clutters up my warnings and makes it difficult for me to find real issues.

Cannot start Dartium Error: spawn EACCES

Hi all,

It's being many days that I try to solve this issue without luck.
The karma config file is:

module.exports = function(config) {
  config.set({
    basePath: '.',
    frameworks: ['dart-unittest'],

    files: [
      {pattern: 'test/angular_ui_tests.dart',  included: true},
      {pattern: '**/*.dart', included: false},
      {pattern: '**/*.html', included: false}
    ],

    exclude: [
    ],

    autoWatch: true,
    captureTimeout: 60000,
    browserNoActivityTimeout: 300000,


    plugins: [
      'karma-dart',
      'karma-chrome-launcher'
    ],

    browsers: ['Dartium']
  });
};

The global variable DARTIUM_BIN is defined. The dartium executable file has permission 777. The file path reported in DARTIUM_BIN is correct.
I can launch dartium manually from command line or from the Dart Editor with no issues.
The error message is too generic and does not help so much:

INFO [karma]: Karma v0.12.28 server started at http://localhost:9876/
INFO [launcher]: Starting browser Dartium
ERROR [launcher]: Cannot start Dartium
        Error: spawn EACCES
INFO [launcher]: Trying to start Dartium again (1/2).
ERROR [launcher]: Cannot start Dartium
        Error: spawn EACCES
INFO [launcher]: Trying to start Dartium again (2/2).
ERROR [launcher]: Cannot start Dartium
        Error: spawn EACCES
ERROR [launcher]: Dartium failed 2 times (cannot start). Giving up.

The operating system is kubuntu 14.04.
nodejs is v0.10.33 and everything works fine except for this issue.
The same issue happens with a direct nodejs installation or through nvm.

Regards
Francesco

Add option for reporting launcher stdout/stderr in Karma log

See karma-runner/karma#1199

I am using Karma to run Native Client, which by default outputs to Chrome stdout/stderr. I'd like to redirect this output the karma log. I have a hack that does this:

var self = this;
var log = logger.create('Chrome stderr');
var oldStart = this._start;

this._start = function(url) {
  oldStart(url);

  var prevStderr = '';
  self._process.stderr.on('data', function(data) {
    var msg = prevStderr + data.toString();
    var start = 0;
    while (true) {
      var end = msg.indexOf('\n', start);
      if (end !== -1) {
        log.info(msg.slice(start, end));
        start = end + 1;
      } else {
        prevStderr = msg.slice(start);
        break;
      }
    }
  });

Is this reasonable to add? Is there a better way to do this?

Karma try open chrome while chrome already opened

  "karma": "^0.12.16",
  "karma-chrome-launcher": "^0.1.4",
  "karma-jasmine": "^0.1.5",
  Chrome Version 49.0.2623.13 dev-m (64-bit)

I am already open chrome before i run the test, it try once report that cannot start chrome then try open it twice

karma issue

Cannot find chrome.app in OSX

In the latest version of the app (0.1.12) the launcher is trying to find the Chrome executable in the home directory (~/Applications/Google Chrome.app) instead of the common one (/Applications/Google Chrome.app)

Version 0.1.9: Unable to find module "which"

I'm hitting the following issue when I upgrade to 0.1.9:

WARN [plugin]: Error during loading "[...]karma-chrome-launcher" plugin:
  Cannot find module 'which'

It looks like which is no longer in the package.json.

chrome process hangs forever

Karma seems have problem disconnecting chrome browser. It happened to me about every 10 tests run. I cannot constantly reproduce this problem

OS: CentOS7
Chrome: Google Chrome 52.0.2743.116
Karma chrome launcher: tried 1.0.1, 0.2.3, 0.1.4, and they all have the problem

Some log:
Finished in 3.517 secs / 2.243 secs

SUMMARY:
✔︎ 9 tests completed
DEBUG [karma]: Run complete, exitting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Disconnecting all browsers
DEBUG [launcher]: Disconnecting all browsers
...then wait forever

The process tree can be found here https://gist.github.com/beeflamian/336735330443814d442fe77fc8e5f9f4

karma config file can be found here
https://gist.github.com/beeflamian/180dc8565e39509c11ee61f6cf844f38

Does anyone have any suggestions? Thanks in advance!

Improve debug cycle

Debugging typically requires the same dance, every time:

  1. Kickoff a karma run (karma start). Chrome launches (with a fresh, new user profile), karma captures it, and runs the tests.
  2. Click the "Debug" button. New browser tab opens at http://localhost:9876/debug.html.
  3. Open DevTools (CMD+OPTION+I). In modern versions of Chrome, DevTools now defaults to 'docked to right', with a width of ~30% of the browser window (far too small for debugging).
  4. (Either) Click the 'dock' toolbar button to switch to 'docked to bottom' mode, OR
  5. Drag the left edge of the DevTools, to maximum width (~%90)
  6. Switch to Sources tab
  7. Add breakpoint(s)
  8. Reload page....and commence debugging.

In a perfect world, clicking the "Debug" button would perform steps 3-6; so that you're automatically dropped into the (appropriately sized) Sources tab, ready to start debugging.

I understand that DevTools cannot be opened programmatically (from JS script), because it isn't sandboxed (the script behind the "Debug" button, which is sandboxed, wouldn't have sufficient privileges to open DevTools); so I can appreciate that step 3 is unlikely to ever be automated. The keyboard shortcut is about as good as we'll ever get (unless there's some Chrome extension that does this, that could be included with the --load-extension option?).

I also understand that because karma-chrome-launcher uses a new profile on each launch; there's nowhere to specify preferences for DevTools such as 'dock to bottom' or 'remember the last used height/width/position'. I checked the list of Chrome CLI switches, but couldn't find any args that would achieve this. I guess the only way it would be possible would be if karma-chrome-launcher could inject settings into the new profile it uses when launching Chrome?

The other thing that particularly annoys me is that I often have a karma-captured Chrome window open for long periods (eg. I use gulp to watch & run tests whenever file is changed).
When I click a URL in an email/Twitter client/etc.. I never want that link to open in the karma-captured Chrome window. I always want it to open in a Chrome window (existing or new) using my Chrome profile. Is there any flag that karma-chrome-launcher can pass to Chrome to say "don't accept external requests from the OS to open links?"

I'm aware of the workaround for making Chrome run in the background (#27); which I guess would prevent links from opening in the background window; but then you lose the ability to debug when required.

That's my wish list, anyway.

Headless chromium for linux

Hi there,

We have been hitting our heads against a wall trying to get browser tests running on Jenkins with mocha and PhantomJS for our browser uploader. Basically, there is a known bug with PhantomJS where attaching a blob doesn't transfer the full file and fails to have correct content-length.

We were thinking about trying to run Chromium on linux in a headless mode to avoid the problems with PhantomJS.

We've seen your issue here and solutions here and here.

Would you be willing to upgrade this module to have a 'headless' option that runs chrome/chromium using xvfb?

Slow test execution if no part of Chrome window is visible

Mac OS X 10.10.3
Google Chrome 42.0.2311.135 (64-bit)

package.json

{
  "name": "slow-karma-tests",
  "version": "0.0.1",
  "devDependencies": {
    "karma": "0.12.32",
    "karma-chrome-launcher": "0.1.8",
    "karma-jasmine": "0.3.5"
  }
}

karma.conf.js

module.exports = function (config) {
    config.set({
        basePath: '',
        frameworks: ['jasmine'],
        files: ['tests/spec.js'],
        reporters: ['progress'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_ERROR,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false
    });
};

tests/spec.js

describe('Hello', function() {
  for (var i = 1; i <= 1000; i++) {
    it('World #' + i, function() {
      expect(true).toBeTruthy();
    })
  }
});

If a part of Chrome window is visible, tests are running as expected:

$ ./node_modules/karma/bin/karma run
Chrome 42.0.2311 (Mac OS X 10.10.3): Executed 1000 of 1000 SUCCESS (2.06 sec / 0.864 secs)

However, if Terminal window is maximized (by double clicking Terminal's title bar), so Chrome window is completely hidden, tests are run unexpectedly slowly:

$ ./node_modules/karma/bin/karma run
Chrome 42.0.2311 (Mac OS X 10.10.3): Executed 1000 of 1000 SUCCESS (50.592 sec / 49.125 secs)

Checking "Prevent App Nap" option for "Google Chrome" doesn't change anything.

It'd be great if Chrome window visibility wouldn't affect test execution time.

Depreciation warning

When used with latest node v7.0.0 and npm 3.10.6 it logs a warning:

(node:4860) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

How to start Chrome with a specific language?

Is there a possibility to tell Karma that it should always start a Chrome instance with an English locale?

My current Karma configuration is this:

// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [process.env.TRAVIS ? 'Chrome_travis_ci' : 'Chrome'],
customLaunchers: {
  Chrome_travis_ci: {
    base: 'Chrome',
    flags: ['--no-sandbox']
  }
}

Karma/Chrome capture timeout on KWin with compositing disabled

So after working just fine during the last few weeks, I today ran 'karma start' on a project only to find that Karma hung trying to capture from Chrome (My projects are currently set up only to capture from Chrome). Other projects did the same. After some headscratching I remembered that I had disabled compositing on KWin while playing Minecraft the night before. Indeed, I had not needed to disable compositing since I started using Karma.

For the unfamiliar, compositing in KWin can be controlled with a keyboard shortcut so its very convenient. If I re-enable compositing, Karma with the Chrome launcher immediately starts and runs my tests. If I turn off compositing, Karma will fail to capture from its instance of Chrome.

So I decided to test some other window managers. Both Compiz and Metacity worked as expected.

Can anyone with a similar set up confirm the issue? You will find the relevant versions from my system below. Let me know if you'd like me to post any other versions.

OS: Linux Mint 17.0 Qiana

$ kwin --version
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
Qt: 4.8.6
KDE Development Platform: 4.14.2
KWin: 4.11.11

$ karma --version
Karma version: 0.13.3

karma-chrome-launcher is version 0.2.0

EDIT:
Also Chrome version:
$ google-chrome-stable --version
Google Chrome 44.0.2403.125

Having problems running karma with jenkins in chrome

After chrome updated today it seems our builds no longer work. interactive shells seem to work, just not in jenkins :(

chrome Version 52.0.2743.82 m
OS: Windows Server 2012 r2

�[4mRunning "karma:continuous" (karma) task�[24m
�[32mINFO [karma]: �[39mKarma v0.12.31 server started at http://localhost:9876/
�[32mINFO [launcher]: �[39mStarting browser Chrome
�[32mINFO [framework.browserify]: �[39m2640391 bytes written (24.08 seconds)
�[32mINFO [framework.browserify]: �[39mbundle built
�[33mWARN [launcher]: �[39mChrome have not captured in 60000 ms, killing.
�[32mINFO [launcher]: �[39mTrying to start Chrome again (1/2).
�[33mWARN [launcher]: �[39mChrome have not captured in 60000 ms, killing.
�[32mINFO [launcher]: �[39mTrying to start Chrome again (2/2).
�[33mWARN [launcher]: �[39mChrome have not captured in 60000 ms, killing.
�[31mERROR [launcher]: �[39mChrome failed 2 times (timeout). Giving up.

Chrome hangs on new start

When I start karma, it starts up a new Chrome instance (as expected). However, the Chrome instance hangs trying to load the page (eventually prompting me to either kill the tab or wait for it). Karma will time out and try to launch chrome again, before it eventually gives up and shuts down. However, I can copy the link that Karma is trying to open, and paste it in another instance of Chrome, and it loads up just fine.
So it seems that there is something wrong with how karma-chrome-launcher is starting up the Chrome instance.
Karma config:

// Karma configuration
// Generated on Tue Oct 13 2015 10:36:06 GMT-0400 (Eastern Daylight Time)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: 'wwwroot',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jspm','jasmine'],


    jspm: {
        loadFiles: [
            'src/**/*.js',
            'test/**/*.js'
        ],
        paths: {
            '*': '*.js'
        },
    },

    // list of files / patterns to load in the browser
    files: [
        'src/**/*.css'
    ],


    // 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: {
        'src/**/*.js': ['babel']
    },
    'babelPreprocessor': {
        options: {
            sourceMap: 'inline',
            modules: 'system',
            moduleIds: false,
            //loose: "all",
            optional: [
              "es7.decorators",
              "es7.classProperties",
              "es7.asyncFunctions",
              "es7.functionBind",
            ]
        }
    },


    // 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
  })
}

I don't think it's necessarily a problem with Karma, as I can use the Firefox launcher, and it works just fine. However, that could be coincidence...

Zombie Chrome process consuming all CPU

Hard to say on what the root cause might be... but with Chrome 50.0.2638, karma-chrome-launcher v0.2.2 we are seeing our tests run complete, but then the docker container never exits:

...
04 02 2016 15:58:25.279:INFO [Chrome 50.0.2638 (Linux 0.0.0)]: Connected on socket /#LeoGJ7ezD3ytuDpBAAAA with id 16900479
Chrome 50.0.2638 (Linux 0.0.0) LOG: 'Running with seed ', 6011
......
Chrome 50.0.2638 (Linux 0.0.0): Executed 6 of 6 SUCCESS (1 min 7.75 secs / 1 min 7.74 secs)

So the tests have finished with SUCCESS but the process never dies.

Reason being (at least based on the investigation I have done so far) is a zombie Chrome process, which also happens to be consuming all the CPU:

KiB Mem:   8175632 total,  4192328 used,  3983304 free,   199416 buffers
KiB Swap:        0 total,        0 used,        0 free.  1325920 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 5739 root      20   0       0      0      0 Z  99.8  0.0   3:23.51 chrome
...

Anyone else seeing this?

Reverting to Chrome stable seems to 'fix' the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.