how to make angularjs e2e-test auto reload after code change - angularjs

when I run the e2e-testing, it does it job but then disconnects when the tests succeed. Is there a way to just have it continuously test?
./scripts/e2e-test.sh
Starting Testacular Server (http://vojtajina.github.com/testacular)
-------------------------------------------------------------------
info: Testacular server started at http://localhost:9876/
info (launcher): Starting browser Chrome
info (Chrome 24.0): Connected on socket id E1loZJU6dCI4eyW9ewyo
Chrome 24.0: Executed 3 of 3 SUCCESS (1.027 secs / 0.697 secs)
info: Disconnecting all browsers

In your testacular/karma config, change/add
autoWatch = True
singleRun = False
You can find the config by opening up your ./scripts/e2e-test.sh and where it says testacular start or karma start the file name should be there. I'm assuming you are using the angular seed or tutorial, in which case the file is located at the config folder usually under something.conf.js

Related

protractor without selenium server

When I issue the protractor command at the command line, with the following configuration:
'use strict';
// Protractor configuration
var config = {
specs: ['test/e2e/*spec.js']
};
if (process.env.TRAVIS) {
config.capabilities = {
browserName: 'firefox'
};
}
exports.config = config;
I get this:
$ protractor
[12:22:23] I/launcher - Running 1 instances of WebDriver
[12:22:23] I/local - Starting selenium standalone server...
[12:22:24] I/local - Selenium standalone server started at http://10.0.0.242:55414/wd/hub
Started
.
1 spec, 0 failures
Finished in 8.223 seconds
[12:22:33] I/local - Shutting down selenium standalone server.
[12:22:33] I/launcher - 0 instance(s) of WebDriver still running
[12:22:33] I/launcher - chrome #01 passed
the problem is that it takes 5+ seconds to start up the "selenium standalone server".
Two questions - (1) do I need this server to run the tests? And (2), is there a way to run the server in the background without having to restart the server everytime?
You also use selenium server jar in the protractor configuration. Checkout the sample bellow. this also comes in handy while using phantojs.
seleniumServerJar: '../utils/selenium-server-standalone-2.53.1.jar',
seleniumPort: 4444,
make user seleniumAddress is commented in the config
Do you use the protractor DirectConnect option? If so, you can also use the standalone webdriver-manager. Protractor also uses it as a dependency.
For local development I installed it as a global with npm install webdriver-manager -g, then update it with webdriver-manager update and start it with webdriver-manager start. It will then run on the background on the default port 4444, run webdriver-manager to see all the options.
You then don't need to start the webdriver for each test / suite.
Hope it helps

angular fullstack generator grunt serve ERR_CONNECTION_REFUSED

I'm building a project on a yeoman angular-fullstack generator. It's been a quite a while and the landing page was correctly loading after running grunt serve task.
I really don't know what I've done but now when I run grunt serve I see ERR_CONNECTION_REFUSED message in chrome first and then the landing page loads normally(about 5 seconds after ERR_CONNECTION_REFUSED message)
This makes my e2e tests crash.
found some issues on github about grunt-concurrent downgrading and disabling livereload but nothing helps..
This is the log. As you see express server has to start listening before open server and watch tasks( newly created fullstack-generator does that so it works correctly)
Running "serve" task
Running "clean:server" (clean) task
>> 1 path cleaned.
Running "env:all" (env) task
Running "concurrent:pre" (concurrent) task
Running "ngconstant:app" (ngconstant) task
Creating module serviceboxApp.constants at client/app/app.constant.js...OK
Done, without errors.
Execution Time (2016-02-26 00:40:08 UTC)
loading tasks 302ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 85%
loading grunt-ng-constant 34ms ▇▇▇▇ 10%
ngconstant:app 19ms ▇▇ 5%
Total 356ms
Running "concurrent:server" (concurrent) task
Running "newer:babel:client" (newer) task
Running "babel:client" (babel) task
Running "newer-postrun:babel:client:1:/Users/apple/Desktop/dev/servicebox/node_modules/grunt-newer/.cache" (newer-postrun) task
Done, without errors.
Execution Time (2016-02-26 00:40:09 UTC)
loading tasks 312ms ▇▇▇▇▇▇▇ 15%
newer:babel:client 36ms ▇ 2%
loading grunt-babel 415ms ▇▇▇▇▇▇▇▇▇ 20%
babel:client 1.2s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 61%
Total 2s
Running "injector:scripts" (injector) task
Missing option `template`, using `dest` as template instead
Injecting js files (33 files)
Running "injector:css" (injector) task
Missing option `template`, using `dest` as template instead
Injecting css files (9 files)
Running "wiredep:client" (wiredep) task
Running "postcss:dist" (postcss) task
Running "express:dev" (express) task
Starting background Express server
Debugger listening on port 5858
[TypeError: Cannot read property 'Kerberos' of undefined]
Running "wait" task
>> Waiting for server reload...
Done waiting!
Running "open:server" (open) task
Running "watch" task
Waiting...
Express server listening on 9000, in development mode
finished populating users
finished populating quotes
finished populating poviders
You have TypeError that is preventing your code from running properly. [TypeError: Cannot read property 'Kerberos' of undefined]
You don't know JS explains that a TypeError "implies that Scope resolution was successful, but that there was an illegal/impossible action attempted against the result."
So you need to go back to where you are calling Kerberos and resolve the TypeError

Can't start the karma server in angular

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.

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.

Set config's 'browsers' property in the command line in karma runner

I usually use browsers=['PhantomJS'] for running my specs with karma because it's faster than chrome and I find a bit annoying when chrome opens the browser in front of the window on every boot.
But when I have a bug and I need to debug, I change karma.conf.js browsers to ['Chrome'].
I would like to set this property when I start karma, something like: 'karma start --browsers=[Chrome]'.
Is this posible?
you just have to use the --browsers parameter and it'll overide your config file browsers part.
$ karma start config/testacular.conf.js --browsers Chrome
where Chrome is the name of the browser or a path to a binary.
For example, I have only a small Qt browser configured. if I use the line above, it runs Chrome instead.
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 24.0 (Linux)]: Connected on socket id DxbVJNX0jIoe1CbaWf9V
Chrome 24.0 (Linux): Executed 74 of 74 SUCCESS (0.443 secs / 0.232 secs)
...
or, for example, I have firefox beta, aurora and release in my home. I run beta with:
$ karma start config/testacular.conf.js --browsers ~/firefox/firefox
$ karma start --help
Karma - Spectacular Test Runner for JavaScript.
START - Start the server / do a single run.
Usage:
karma start [<configFile>] [<options>]
Options:
--port <integer> Port where the web server is running.
--runner-port <integer> Port where the server is listening for runner.
--auto-watch Auto watch source files and run on change.
--no-auto-watch Do not watch source files.
--log-level <disable | error | warn | info | debug> Level of logging.
--colors Use colors when reporting and printing logs.
--no-colors Do not use colors when reporting or printing logs.
--reporters List of reporters (available: dots, progress, junit).
--browsers List of browsers to start (eg. --browsers Chrome,ChromeCanary,Firefox).
--capture-timeout <integer> Kill browser if does not capture in given time [ms].
--single-run Run the test when browsers captured and exit.
--no-single-run Disable single-run.
--report-slower-than <integer> Report tests that are slower than given time [ms].
--help Print usage and options.
--version Print current version.

Resources