Can't start the karma server in angular - angularjs

Hi I'm trying to get the test script running on the angular tutorial (step 2, writing and running test part 1) but I'm stuck at trying to run the karma server but when I run the command in the GitBash terminal I get this error
John#JOHN-PC ~/angular-phonecat ((step-2))
$ ./scripts/test.sh
Starting Karma Server (http://karma-runner.github.io)
-------------------------------------------------------------------
INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
ERROR [launcher]: Cannot start Chrome
Can not find the binary C:\Users\John\AppData\Local\Google\Chrome\Applic
ation\chrome.exe
Please set env variable CHROME_BIN
any idea what this means
here's the link to the tutorial http://docs.angularjs.org/tutorial/step_02

As Cristian Ternus had already pointed out you will have to set the correct value of the CHROME_BIN env variable. Dont copy the path as it is provided in the comment. You will have to find out where crome.exe is present on your machine. Please refer http://bardevblog.wordpress.com/2013/07/28/setting-up-angularjs-angular-seed-node-js-and-karma/ which is a nice tutorial about running angular test cases. Step 8 in the tutorial is addressing your issue.

Do you have Google Chrome installed? If not, install it.
If it's installed, is it in that path (C:\Users\John\AppData\Local\Google\Chrome\Applic
ation\chrome.exe)?
If not, set the environment variable CHROME_BIN to the path of chrome.exe.

Related

I am getting issue phantomjs and karma

I am facing issue while running grunt, it throwing me following issue:
ERROR [launcher]: PhantomJS2 failed 2 times (timeout). Giving up.
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers
Warning: Task "karma:continuous" failed. Use --force to continue.
I tried to run npm install phantomjs
Which is successful. After that i run npm install as well but again getting above issue
This is because you will need to run the PhantomJS standalone version for karma to connect to it.
I would suggest a better option according to my opinion, which is to use karma-phantomjs2-launcher. You can get that by: npm install --save-dev karma-phantomjs2-launcher.
Please note that it is not a stable version. If it suits your requirement, you can use karma-phantomjs-launcher, which works perfectly fine. But it does not have support for PhantomJS 2.
I got solution for this, if we get this error so first need to check karm.conf.js file, there you have to search for key browsers and in that section you have to see whether PhantomJS2 is defined or not.It would be something like this:
browsers : [
'PhantomJS2'
],
In my case it was there but still i was getting error, i then checked my hosts file which you can find in C:\Windows\System32\drivers\etc if you are using windows machine and i placed
127.0.0.1 localhost and there i go.... its worked for me.

Running AngularJS Protractor with IE11

I am having trouble running AngularJS Protractor through Internet Explorer 11 on Windows 7. It works fine if I use Google Chrome, but with IE11, I get the following error message:
WebDriverError: The path to the driver executable must be set by the webdriver.ie.driver system property: for more information, see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html
Within the protractor directory is a sub-directory called selenium, and there is an IEDriverServer file. Furthermore, I have two environment variables set. In my user variables, the variable PATH has a value of C:\Users\user\AppData\Roaming\npm\node_modules\protractor\selenium\
Additionally, in my system variables, the variable "Path" is also set to C:\Users\user\AppData\Roaming\npm\node_modules\protractor\selenium\, but it will still not recognize the IE driver server, even though it DOES recognize the Chrome driver server.
Does anyone have any additional information on what I might be missing or doing wrong? Thank you very much.

angularjs tutorial: test ERROR, no more info

This is my first time using Angular (and Karma), so please excuse me if this is a total beginner's question: that's what I am.
I'm trying to run the Angular-phonecat tests, as described in Step 02 - Writing and Running Tests
My code is checked out directly from the step 2 branch (git checkout -f step-2)
When running the test (angular-phonecat\scripts> test), I'm given the following message:
INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 30.0.1599 (Windows 7)]: Connected on socket Jw-2z-zZ-pytGNN-SHRM
Chrome 30.0.1599 (Windows 7): Executed 0 of 0 ERROR (0.472 secs / 0 secs)
There is no more information given, and I cannot find any log the would detail the problem (nothing in /test or its sub-directories, nor in /logs). I also cannot find a log for karma in general - is there one?
You need to add this line to karma.conf.js
exclude: ['app/lib/angular/angular-scenario.js'],
Theres an issue relating to this problem here: https://github.com/angular/angular-phonecat/issues/71
Hi i started today with angular and karma aswell, im on a mac and i have the same problem.
I joined the IRC channel #angularjs at freenode and asked for some help and this is the answer that i got.
[16:59] <Wirde> Hi, I just started with the Angular-phonecat tutorial, after installing karma and the adapters I got too step 2 but when I try to run the unit tests it gives me the error: Executed 0 of 0 ERROR (0.327 secs / 0 secs). Can some please tell me whats wrong?
[17:00] <dmco> Wirde: I think phonecat is wonky after some 1.2rcX upgrades
[17:01] <dmco> Wirde: Another guy was complaining about issues with it yesterday
[17:02] <Wirde> dmco: hi, thanks for the answer, how do you suggest i proceed? Is there another good way to learn about karma and testing with angular?
[17:02] <rdepena> http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-karma.html#karma
[17:02] <dmco> Wirde: One easy way would be to scaffold a new project using Yeoman and the AngularJS generator
[17:02] <rdepena> this is a great source
[17:02] <dmco> ^^ Wirde that is a good link too
[17:03] <Wirde> dmco: rdepena: Thank you for the help! I will check it out :D
Not sure if this is the response that you wanted or if its enought but i tought i might share it.

Access error running chrome from grunt test

I am trying to run karma tests on my angular project. I used yeoman to create the angular project. However when I am trying to run tests, I am getting following errors
grunt test
Running "clean:server" (clean) task
Running "concurrent:test" (concurrent) task
Running "coffee:dist" (coffee) task
Running "coffee:test" (coffee) task
Done, without errors.
Running "connect:test" (connect) task
Started connect web server on localhost:9000.
Running "karma:unit" (karma) task
INFO [karma]: Karma server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern "/home/arpit/proj/proj1/views/test/mock/**/*.js" does not
match any file.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
INFO [launcher]: Trying to start Chrome again.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
INFO [launcher]: Trying to start Chrome again.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
Warning: Task "karma:unit" failed. Use --force to continue.
Aborted due to warnings.
I can run chrome from bash using same account successfully with which I am trying to run grunt test
Also, sudo grunt test is running fine.
On the Mac, it's important to set CHROME_CANARY_BIN
to binary file, not just to app package.
In my case, problem emerged from installing Chrome via brew cask, so I had to set
export CHROME_CANARY_BIN="/opt/homebrew-cask/Caskroom/google-chrome-canary/latest/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
In most cases you have to set a environment variable "CHROME_BIN" to point at your chrome.exe
Windows:
set CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Mac 10.7.5
I was able to set it using the following
export CHROME_BIN=/Applications/Chrome.app/Contents/MacOS/Google\ Chrome
You get to the exec file by right clicking on the .app and selecting the Show Package Contents option. Follow this down to the executable and click it. It brought up the path in the terminal.

Angularjs tutorial step2 test chrome not start with Error write EIO

My pc is Windows7 32bit.
When I test Angularjs tutorial step2.
Chrome not start with error.
--- versions ---
Angularjs:1.0.2
testacular:0.4.0
--- messages ----
info: Testacular server started at http://localhost:9876/
info (launcher): Starting browser chrome
error (launcher):
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: write EIO
at errnoException (net.js:770:11)
at Object.afterWrite (net.js:594:19)
Refer: https://github.com/angular/ang...
start scripts/test.sh (on windows: scripts\test.bat)
In the Git Shell / command window, go to the angular-phonecat directory. Enter this command
scripts\test.bat
Please note it test.bat and not .sh file.
You can see that the server
started but it may throw error that Chrome cannot be started and it is unable to find the path. I too was stopped at this point and anyhow after several reference, got this solution.
Open config/testacular.conf.js in some editor. Change the
browsers = ['Chrome'] to
browsers = ['C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'];
(This is where my Chrome is installed in Windows 8). You may need to get the correct installation path along with the chrome.exe in path and should use forward-slash
otherwise it will not work.
It is working for me now!

Resources