31

I'm trying to use Karma for testing my js scripts. In the doc it says I should set the environment variable for CHROME_BIN:

I've set it to

%programfiles(x86)%"\Google\Chrome\Application\Chrome.exe

but when I type %CHROME_BIN% in DOS, it fails as it's truncated to C:\Program of the space in Program Files.

What can I do to work around with this problem?

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
Sam
  • 13,934
  • 26
  • 108
  • 194

9 Answers9

43

Was facing the same issue and I solved it by editing the karma.conf.js and karma-e2e.conf.js files which is under config directory.

Change:

browsers = ['Chrome'];

TO

browsers = ['Your_System_Path_where_chrome_installed/chrome.exe'];

in my case it was > C:/Program Files (x86)/Google/Chrome/Application/chrome.exe

and then add C:\Program Files (x86)\Google\Chrome\Application\chrome.exe path to environment variables


or in cmd

SET CHROME_BIN = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

Additional: Settings for other browsers can be seen here.

And about why chrome one is not working I guess they(Karma) have configured their chrome path from some earlier versions of chrome.


Update: For AngularJS tutorial Followers:

  • You still might face problems (as I faced) while running karma test runner on some tutorial steps and to resolve this: just add these "Angular Scenario Dependencies" in both the "...conf.js" files, like this:
files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
    ....
    ....  // keep rest of the lines as it is
    ....
];
exexzian
  • 7,782
  • 6
  • 41
  • 52
  • 1
    this fixed my problem with `CHROME_BIN` not being set – pbojinov Jun 25 '13 at 23:30
  • 1
    following the angularJS tutorial, couldn't get it to work with env variables, nor with setting the path to chrome directly into karma conf files. What worked instead, is using default windows cmd and doing SET CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe I assume this edits the env variable but for some reason, it didn't work with default env variables in computer->advanced system settings. Notice that my karma totally ignores what I setup in conf files, right now it is stated browsers = ['PhantomJS']; and it launches on chrome – Rayjax Sep 19 '13 at 08:10
  • setting CHROME_BIN environment also works with the note that you must open a new command prompt after the change – Răzvan Flavius Panda Oct 25 '13 at 02:39
  • In case you need Chromium on Linux Mint then change browsers: ['Chrome'], to browsers: ['Chromium'], in karma.conf.js – Tertius Geldenhuys Aug 21 '18 at 00:32
7

In Powershell you can run the following command:

$Env:CHROME_BIN = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

You need to replace the stuff within the double quotes with your local path.

Or in cmd.exe

SET CHROME_BIN = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

This is all you would need to get it going.

mithun_daa
  • 4,334
  • 5
  • 38
  • 50
  • 3
    I think that important thing to note is that, at least when working with cmd, it requires to restart cmd to work. Without restart after SET CHROME_BIN command it still doesn;t recognize this. After restart, everything is ok. – Rob Oct 13 '13 at 17:50
  • Thats @RobertJagoda **Restart** was very important! I wasted so much time trying to figure it out how it works. And then I saw your comment! – Kuldeep Daftary Oct 14 '13 at 15:10
5

I have solved the same issue by setting CHROME_BIN in my environment properties like this:

c:/Program Files (x86)/Google/Chrome/Application/chrome.exe

There have to be no double quotes (") around the property value and all backslash signs (\) have to be replaced by slash signs (/)

Josef Vlach
  • 379
  • 4
  • 7
3

For Chromium in ubuntu 14.04 edit test/karma.conf.js and change

browsers = ['Chrome'];

for

browsers = ['chromium-browser'];
1

I've found that installing Canary and changing browsers = ['Chrome']; to browsers = ['ChromeCanary']; is nicer.

WraithKenny
  • 1,001
  • 13
  • 15
1

I solved the problem by running from an Administrator Command Prompt. No need to set CHROME_BIN and it will automatically point to your default installation.

Atul Soman
  • 4,612
  • 4
  • 30
  • 45
0

Use set (see http://ss64.com/nt/set.html) and place the quotes around the entire string

"%programfiles(x86)%\Google\Chrome\Application\Chrome.exe"

Shmil The Cat
  • 4,548
  • 2
  • 28
  • 37
  • It's driving me nut. I've tried everything and I still can't get it to work. I even tried with powershell : [System.Environment]::SetEnvironmentVariable("CHROME_BIN", "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe") but no luck. Any idea what else I can try ? – Sam Apr 15 '13 at 19:33
  • @Sam sometimes those hiccups related to non admin mode, make sure you set the variable as _admin_ – Shmil The Cat Apr 15 '13 at 19:43
  • I'm definitely admin on my computer (I've tried both on my work computer and my personal computer, same problem) – Sam Apr 15 '13 at 20:05
0

(In Linux) I thought it was related to CHROME_BIN but in the end for me it had nothing to do with that variable and i removed it. I had to lookup the karma-chrome-launcher npm plugin on github and follow the instructions for adding no security to my karma config.

Post Impatica
  • 14,999
  • 9
  • 67
  • 78
0

In addition, some of us may have our chrome.exe file in the Program Files directory and not Program Files (x86), as a 64-bit application. So, the path may look like this:

C:\Program Files\Google\Chrome\Application\chrome.exe