I set up a standard yeoman/angular installation on Mac OS X 10.8.3 using npm. I created a new angular project using the yo generator. I installed phantomjs via npm install -g phantomjs. I configured karma to unly use phantomjs (all other browsers work fine). When running tests with grunt test, phantomjs does not capture at all, even if I set a very long timeout (50000ms). This is the log output:
Running "karma:unit" (karma) task
DEBUG [reporter]: Using reporter "progress".
INFO [karma]: Karma server started at http://localhost:8080/
INFO [launcher]: Starting browser PhantomJS
DEBUG [launcher]: Creating temp dir at /var/folders/6j/gz50dm2d3xv1hnz7s1t4lhn40000gp/T/testacular-79891032
DEBUG [launcher]: /usr/local/bin/phantomjs /var/folders/6j/gz50dm2d3xv1hnz7s1t4lhn40000gp/T/testacular-79891032/capture.js
WARN [watcher]: Pattern "/Users/alexanderwalter/Development/angularSeed/test/mock/**/*.js" does not match any file.
DEBUG [watcher]: Resolved files:
/Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/adapter/lib/jasmine.js
/Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/adapter/jasmine.js
/Users/alexanderwalter/Development/angularSeed/app/components/angular/angular.js
/Users/alexanderwalter/Development/angularSeed/app/components/angular-mocks/angular-mocks.js
/Users/alexanderwalter/Development/angularSeed/app/scripts/app.js
/Users/alexanderwalter/Development/angularSeed/app/scripts/controllers/add.js
/Users/alexanderwalter/Development/angularSeed/app/scripts/controllers/main.js
/Users/alexanderwalter/Development/angularSeed/test/spec/controllers/add.js
/Users/alexanderwalter/Development/angularSeed/test/spec/controllers/main.js
DEBUG [web server]: serving: /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/static/client.html
DEBUG [web server]: serving: /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/static/testacular.js
DEBUG [karma]: New browser has connected on socket wxBffi5IEZn9zQvoTm0J
WARN [launcher]: PhantomJS have not captured in 50000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 1
ERROR [launcher]: Cannot start PhantomJS
As I said, it works for all other browsers. Phantomjs also works if I pass it a simple test script which prints hello world to the console.
I had the same issue and found out it was a problem with nodejs 0.10.8/0.10.9: https://github.com/karma-runner/karma/issues/558
Downgrading to nodejs 0.10.7 solved the problem for me.
In case you want to go with node 0.10.11, the Proxy option worked for me (Mac 10.6.8, Karma 0.8.5, and node 0.10.11 or 0.10.7. Node 0.10.8/9/10 didn't work.).
Inside the karma.conf.js file:
proxies = {
'/': 'http://localhost:9000'
};
urlRoot = '/__unit/';
Inside the karma-e2e.conf.js file:
proxies = {
'/': 'http://localhost:9000'
};
urlRoot = '/__e2e/';
I upgraded to the latest stable version of Node.js. This solved it for me. currently v.10.20.
Related
I'm using webdriverIO for some automation testing and have recently migrated from 'selenium-standalone' service to default wdio devtools protocol.
wdio v.7.16.12
firefox v.95.0.2
From that point I can't start testing with firefox browser:
INFO #wdio/cli:launcher: Run onPrepare hook
INFO #wdio/cli:launcher: Run onWorkerStart hook
INFO #wdio/local-runner: Start worker 0-0 with arg: run,wdio.conf.js
INFO #wdio/local-runner: Run worker command: run
...
INFO devtools:puppeteer: Initiate new session using the DevTools protocol
ERROR #wdio/runner: Error: Couldn't find executable for browser
...
INFO #wdio/cli:launcher: Run onComplete hook
I've tried different combinations of options with 'wdio:devtoolsOptions' and 'moz:firefoxOptions'.
Plus checked whether could help dumpio: true, and 'moz:debuggerAddress': true options.
Also I've tried substitution browserName with product and adding binary and executablePath to capabilities.
When passing binary: 'path.to.firefox' to 'moz:firefoxOptions' options, the error message changes to:
ERROR #wdio/runner: Error: Only Nightly release channel is supported in Devtools/Puppeteer for Firefox. Refer to the following issue:
...
Any ideas how it could be fixed in webdriverIO (without installing separately puppeteer or puppeteer-firefox)?
Thanks!
Seems that I took desired for real.
wdio + devtools:puppeteer still work with Firefox Nightly only – https://github.com/webdriverio/webdriverio/discussions/7916
Any idea how you can run Karma unit tests inside VSTS? Do they have to be integrated with the Visual Studio Test Runner or is there a better way?
The project is purely client-side static SPA website so it has no Visual Studio solution or project.
Also It seems like even when I try to run Karma via NPM it seems like PhantomJS refuses to start on the Agent.
Logs from the Build:
2016-08-03T02:45:44.9647601Z webpack: bundle is now VALID.
2016-08-03T02:45:44.9717626Z [32m03 08 2016 02:45:44.968:INFO [karma]: [39mKarma v0.13.22 server started at http://localhost:9876/
2016-08-03T02:45:44.9767811Z [32m03 08 2016 02:45:44.976:INFO [launcher]: [39mStarting browser PhantomJS
2016-08-03T02:46:44.9784272Z [33m03 08 2016 02:46:44.977:WARN [launcher]: [39mPhantomJS have not captured in 60000 ms, killing.
2016-08-03T02:46:46.9783856Z [33m03 08 2016 02:46:46.977:WARN [launcher]: [39mPhantomJS was not killed in 2000 ms, sending SIGKILL.
2016-08-03T02:46:48.9792421Z [33m03 08 2016 02:46:48.978:WARN [launcher]: [39mPhantomJS was not killed by SIGKILL in 2000 ms, continuing.
2016-08-03T02:46:49.1602394Z npm ERR! Test failed. See above for more details.
2016-08-03T02:46:49.1722407Z ##[debug]rc:1
2016-08-03T02:46:49.1722407Z ##[debug]success:false
2016-08-03T02:46:49.1722407Z ##[debug]taskRunner fail
2016-08-03T02:46:49.1732408Z ##[debug]task result: Failed
2016-08-03T02:46:49.1782402Z ##[error]Npm failed with error: C:\Program Files\nodejs\npm.cmd failed with return code: 1
2016-08-03T02:46:49.1962405Z Finishing task: Npm
2016-08-03T02:46:49.2032405Z ##[error]System.Exception: Task Npm failed. This caused the job to fail. Look at the logs for the task for more details.
2016-08-03T02:46:49.2042402Z ##[error] at Microsoft.TeamFoundation.DistributedTask.Worker.JobRunner.Run(IJobContext jobContext, IJobRequest job, IJobExtension jobExtension, CancellationTokenSource tokenSource)
I'm not sure what is your configuration of steps, but it's works perfectly fine on my build definition.
Check also capabilities of your agent, should have node.js and npm capability.
I've got a problem with my CI setup.
Since a couple of days Firefox doesn't run our Jasmine tests with Karma anymore.
But Chrome does - so the error should not depend on the tests themselves.
On my development environment it runs as well.
I did not change anything on the CI-server (Ubuntu).
What happens:
Firefox is connecting to the web-server and establishes a session.
But the tests are not executed.
What I already tried:
I already changed the timeout.
I already restarted the machine (a couple of times).
And I already reinstalled firefox.
Do you have an idea, what causes this strange behaviour or how I can debug this?
We are using
karma#0.12.37
karma-jasmine#0.3.5
karma-firefox-launcher#0.1.6
Firefox v.38.0
Ubuntu
nodejs v.0.10.25
npm v 1.3.10
Xvfb
karma.conf.js
module.exports = function(config) {
config.set({
browserNoActivityTimeout: 100000,
basePath: 'src/main/webapp/',
singleRun: true,
// autoWatch: true,
logLevel: config.LOG_DEBUG,
files: [
'assets/libs/jquery/dist/jquery.min.js',
'assets/libs/angular/angular.min.js',
'assets/libs/angular-mocks/angular-mocks.js',
'assets/libs/**/*.min.js',
'app/app.js',
'app/**/*.js',
'app/directives/*/*.html',
'app/directives/*/*.js',
'../../test/frontend/**/*.js', {
pattern: 'assets/libs/**/*.map',
included: false
},
'app/views/*.html'
],
preprocessors: {
'app/views/*.html': 'ng-html2js',
'app/directives/*/*.html': 'ng-html2js'
},
frameworks: ['jasmine'],
browsers: [
'Firefox'
],
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-safari-launcher',
'karma-ie-launcher',
'karma-jasmine',
'karma-junit-reporter',
'karma-ng-html2js-preprocessor'
],
reporters: ['progress', 'junit'],
junitReporter: {
outputFile: '../../../build/test-results/karma-test-results.xml'
},
ngHtml2JsPreprocessor: {
moduleName: 'myc-templates'
}
});
};
Output of 'xvfb-run karma start'
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser Firefox
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-70931573
DEBUG [launcher]: firefox http://localhost:9876/?id=70931573 -profile /tmp/karma-70931573 -no-remote
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/karma.js
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/favicon.ico
DEBUG [web-server]: upgrade /socket.io/1/websocket/5wtT2gW7_XuaTRZ3Gctt
DEBUG [karma]: A browser has connected on socket 5wtT2gW7_XuaTRZ3Gctt
INFO [Firefox 38.0.0 (Ubuntu 0.0.0)]: Connected on socket 5wtT2gW7_XuaTRZ3Gctt with id 70931573
DEBUG [launcher]: Firefox (id 70931573) captured in 3.542 secs
DEBUG [web-server]: serving: /var/lib/jenkins/jobs/MYC/workspace/node_modules/karma/static/context.html
DEBUG [Firefox 38.0.0 (Ubuntu 0.0.0)]: Disconnected during run, waiting 2000ms for reconnecting.
WARN [Firefox 38.0.0 (Ubuntu 0.0.0)]: Disconnected (1 times)
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [reporter.junit]: JUnit results written to "/var/lib/jenkins/jobs/MYC/workspace/build/test-results/karma-test-results.xml".
DEBUG [launcher]: Process Firefox exited with code 0
DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-70931573
npm ERR! weird error 1
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
Any tipps or ideas how to solve this are very much appreciated ;-)
Thanks, Sebastian
Setup a new angular project under linux. Committed it to git and cloned it to windows. Using bower and npm, I managed to get everything loaded, except, I have this one error (only on windows)
A recursive grep for ../time/convert in the project shows me:
./node_modules/grunt-contrib-imagemin/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/mout/date/diff.js:var convert = require('../time/convert');
./node_modules/grunt-contrib-imagemin/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/mout/src/date/diff.js:define(['./totalDaysInMonth', './totalDaysInYear', '../time/convert'], function(totalDaysInMonth, totalDaysInYear, convert){
./node_modules/grunt-contrib-imagemin/node_modules/optipng-bin/node_modules/bin-wrapper/node_modules/mout/date/diff.js:var convert = require('../time/convert');
./node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/node_modules/bin-wrapper/node_modules/mout/date/diff.js:var convert = require('../time/convert');
./node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/node_modules/bin-wrapper/node_modules/mout/src/date/diff.js:define(['./totalDaysInMonth', './totalDaysInYear', '../time/conve
but ls -l shows:
$ ls ./node_modules/grunt-contrib-imagemin/node_modules/gifsicle/node_modules/bin-wrapper/node_modules/mout/time
convert.js now.js parseMs.js toTimeString.js
Which says that convert.js is actually there. Being new to grunt and angular, I'm puzzled where this could be coming from and how to troubleshoot it.
After this I end up getting stuck here:
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.10.4 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern ".../test/mock/**/*.js" does not match any file
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start Chrome again.
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
INFO [launcher]: Trying to start Chrome again.
Wondering if angular work using grunt is just not possible on Windows....
My solution was to quit using windows. Moved dev work to linux, and no more crazy problems like this. Oh, and my machine now seems a good deal faster too.
I'm running test using behat, but this basically runs phpunits selenium driver, to do integration tests
everything was working fine but for no apparent reason firefox quits at some point in the middle of my test suite the selenium rc log looks like this
09:23:53.157 INFO - Command request: setTimeout[30000, ] on session 62b513ea550a419898a79f912beecc69
09:23:53.180 INFO - Got result: OK on session 62b513ea550a419898a79f912beecc69
09:23:53.263 INFO - Command request: open[/request/step1, ] on session 62b513ea550a419898a79f912beecc69
09:23:53.318 INFO - Got result: XHR ERROR: URL = http://local-test.account/request/step1 Response_Code = -1 Error_Message = Request Error on session 62b513ea550a419898a79f912beecc69
09:23:53.321 INFO - Command request: testComplete[, ] on session 62b513ea550a419898a79f912beecc69
09:23:53.321 INFO - Killing Firefox...
09:23:53.356 INFO - Got result: OK on session 62b513ea550a419898a79f912beecc69
09:23:53.371 INFO - Command request: open[/request/step1, ] on session null
09:23:53.374 ERROR - Exception running 'open 'command on session null
at what point in the test it quits doesn't seem to follow any pattern.
i've tried rolling my projects code back to before I was having problems but to no avail
If you are using Selenium 1.3, try upgrading to Selenium 2.0. Here is how I resolved my problem with selenium.open();
This is possible when you are not passing correct website address. What are you passing, what is the URL of your website.