Angular-cli: ng test browser capture timeout issue

Created on 15 Feb 2017  路  5Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Windows 10

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
1.0.0-beta.31

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
run ng test on slow machine.

The log given by the failure.

Normally this include a stack trace and some more information.
14 02 2017 15:51:47.924:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9876/
14 02 2017 15:51:47.926:INFO [launcher]: Launching browser Chrome with unlimited concurrency
14 02 2017 15:51:48.262:INFO [launcher]: Starting browser Chrome
14 02 2017 15:51:49.888:ERROR [launcher]: Cannot start Chrome

14 02 2017 15:51:51.122:ERROR [launcher]: Chrome failed 0 times (cannot start). Giving up.
14 02 2017 15:51:51.719:INFO [Chrome 56.0.2924 (Windows 7 0.0.0)]: Connected on socket Ip7Jk-wjVEYSiLOXAAAA with id 56789584
Chrome 56.0.2924 (Windows 7 0.0.0): Executed 0 of 16 SUCCESS (0 secs / 0 secs)

Mention any other details that might be useful.

I tried to set captureTimeout in karma.config.js but it doesn't seem to change anything. Gives up too quick. Browser does start but by than its too late.

Most helpful comment

This is an environment specific issue that only some projects will face, hence the CLI doesn't account for.

It's a karma config issue too, so, in my project, where I face something similar, I modified karma.conf.js to include:

module.exports = function (config) {
  config.set({
    ...
    ...
    // Based on: https://github.com/karma-runner/karma/issues/598#issuecomment-160977724
    captureTimeout: 60 * 1000,
    browserDisconnectTimeout: 15 * 1000,
    browserDisconnectTolerance: 5,
    browserNoActivityTimeout: 15 * 10000,
  });
};

It might also be a version issue. In my project we had this happen on the CLI server so we ended up using Chrome Portable instead, works nicely.

Something like:

var chromePath = path.join(__dirname, "./tools/Chrome/App/Chrome-bin/chrome.exe");
var browsers = [chromePath];
var customLaunchers = {};
customLaunchers[chromePath] = {
  base: 'Chrome'
};

module.exports = function (config) {
  config.set({
    ...
    customLaunchers: customLaunchers,
    browsers: browsers,
    ...
  });
};

All 5 comments

This is an environment specific issue that only some projects will face, hence the CLI doesn't account for.

It's a karma config issue too, so, in my project, where I face something similar, I modified karma.conf.js to include:

module.exports = function (config) {
  config.set({
    ...
    ...
    // Based on: https://github.com/karma-runner/karma/issues/598#issuecomment-160977724
    captureTimeout: 60 * 1000,
    browserDisconnectTimeout: 15 * 1000,
    browserDisconnectTolerance: 5,
    browserNoActivityTimeout: 15 * 10000,
  });
};

It might also be a version issue. In my project we had this happen on the CLI server so we ended up using Chrome Portable instead, works nicely.

Something like:

var chromePath = path.join(__dirname, "./tools/Chrome/App/Chrome-bin/chrome.exe");
var browsers = [chromePath];
var customLaunchers = {};
customLaunchers[chromePath] = {
  base: 'Chrome'
};

module.exports = function (config) {
  config.set({
    ...
    customLaunchers: customLaunchers,
    browsers: browsers,
    ...
  });
};

All these timeouts don't seem to have any impact. It just waits about a second and gives up no matter what.
But there's something interesting. If I don't have any Chrome windows open then it works. It will start a browser, wait, run tests, close the browser and exit. But if Chrome is already running it will open a new tab (not window) and give up after a sec.
On my other machine it always opens a new window, not a tab no matter if Chrome is running or not.

If the behaviour stays different even after deleting node_modules and installing npm again, it may not be a CLI issue or even a karma issue.

Things to try:

  • Ensure both browsers are latest version of Chrome

  • Completely delete Chrome and reinstall it. Look for files on your user and app data folders. In early versions of Chrome, it installed in user folder, while newer versions install in program files. If you had Chrome since the old user folder days, it sometimes acts weird. I had this before in old machines

Closing because this doesn't seem to be a CLI issue. I'd say to ask around https://github.com/karma-runner/karma describing what you see happening with the tab vs new window behaviour.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings