karma-runner / karma-chrome-launcher

A Karma plugin. Launcher for Chrome and Chrome Canary.
MIT License
467 stars 119 forks source link

chrome.desktop shortcut on ubuntu broken #112

Open zladuric opened 7 years ago

zladuric commented 7 years ago

Expected behaviour

Karma Launcher shouldn't change my chrome.desktop shortcut, when running it on Ubuntu.

Actual behaviour

After karma ran Chrome for me, I sometimes get chrome open with no profile and pointing to this url: http://localhost:9876/?id=61917528.

What happened is that I've ran npm test in a practically brand new angular-cli project. Since then, my desktop shortcut gets occassionally replaced (or created if I delete it), adding this to the "Exec" line:

Exec=/opt/google/chrome/chrome --user-data-dir=/tmp/karma-63694901 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-device-discovery-notifications http://localhost:9876/?id=63694901

I've reported this in angular-cli first and was directed here. I'm not sure if this is something karma-specific, but it's defiunitely karma-related so I'm reporting here.

I'll try to reproduce or to hunt down the issue, but if somebody can help out with some guidelines, it would help a lot.

Environment Details

Pretty much basic config that I got with ng new:

  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    files: [
      { pattern: './src/test.ts', watched: false }
    ],
    preprocessors: {
      './src/test.ts': ['@angular/cli']
    },
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
              ? ['progress', 'coverage-istanbul']
              : ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

Steps to reproduce the behaviour

As said above, I'm not sure if I can reproduce,

Daskus1 commented 6 years ago

I have the exact same problem. Is there a fix for this?

Sakuni commented 6 years ago

Is there a fix for this?

Sakuni commented 6 years ago

Removing globally installed Karma from "npm uninstall -g karma" and reinstalling google chrome solved the issue for me. ng test in angular-cli works fine too. I have below devDependencies in my package.json. "karma": "1.7.1", "karma-chrome-launcher": "2.2.0", "karma-cli": "1.0.1", "karma-coverage-istanbul-reporter": "1.3.0", "karma-firefox-launcher": "1.0.1", "karma-jasmine": "1.1.0", "karma-jasmine-html-reporter": "0.2.2",

chrispinzaru commented 5 years ago

@zladuric, @Sakuni
For everyone who stumbled upon this bug, I've got the solution for Ubuntu 16.04 (or below).

Basically by installing karma globally it mutates (changes) your desktop (dash) entries. To fix this you need to start Terminal (Ctrl + Alt + T on Ubuntu) and : cd ~/.local/share/applications - go to the path where desktop entries are placed

There will be at least 2 desktop entries - chrome.desktop and google-chrome.desktop Next edit one of them, e.g.: gedit chrome.desktop or nano chrome.desktop - use an editor to edit chrome.desktop entry

Than you'll find a line like this inside: Exec=/opt/google/chrome/chrome --user-data-dir=/tmp/karma-29871921 ... - remove all flags after /chrome starting with --user-data-dir

Save and close file (Ctrl + O, Ctrl + X in nano)

Now depending on which file you edited, you should be able to start normally the Chrome from Dash.

Hope this helps, cheers.