karma: Karma is not able to run test cases on phantomJS
I have been trying to get Karma to run tests on PhantomJS for the last couple of hours and seem to be stuck at it. I had my entire suit run tests in Chrome and it ran without a quirk. on trying to run it with Karma, it would just not run.
I was running phantomjs 1.9 and then i reverted to 1.8. i tried installing it from the distributed binary from the phantomjs site and i also tried to install it through npm. But i had no avail in any of the combinations. I am on a 64bit Ubuntu machine.
I am pretty sure my configurations are correct and i checked phantomjs which again seems to be working.
Am i missing something here. or is this some bizarre bug.
I am attaching my debug logs below.
DEBUG [reporter]: Using reporter "dots".
DEBUG [reporter]: Using reporter "junit".
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
DEBUG [launcher]: Creating temp dir at /tmp/testacular-86450027
DEBUG [launcher]: phantomjs /tmp/testacular-86450027/capture.js
DEBUG [watcher]: Resolved files:
/home/kausikram/lib/node_modules/karma/adapter/lib/jasmine.js
/home/kausikram/lib/node_modules/karma/adapter/jasmine.js
/home/kausikram/Projects/scloud/src/main/webapp/resources/jquery/jquery.js
/home/kausikram/Projects/scloud/src/main/webapp/resources/jquery/jquery.dynoform.js
[...]
DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/client.html
DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/testacular.js
DEBUG [karma]: New browser has connected on socket s2jUXmnylvNYdQux4Wc2
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 1
ERROR [launcher]: Cannot start PhantomJS
DEBUG [launcher]: Cleaning temp dir /tmp/testacular-86450027
INFO [launcher]: Trying to start PhantomJS again.
DEBUG [launcher]: Creating temp dir at /tmp/testacular-86450027
DEBUG [launcher]: phantomjs /tmp/testacular-86450027/capture.js
DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/client.html
DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/testacular.js
DEBUG [karma]: New browser has connected on socket 3qsGGwLPK5ogNJs_4Wc3
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
DEBUG [launcher]: Process PhantomJS exitted with code 1
ERROR [launcher]: Cannot start PhantomJS
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 105 (10 by maintainers)
Commits related to this issue
- disable travis until we can get it working again need to switch to protractor and deal with https://github.com/karma-runner/karma/issues/558 — committed to getlantern/lantern-ui by lanterndev 10 years ago
- disable tests until we can get them working again need to switch to protractor and deal with https://github.com/karma-runner/karma/issues/558 — committed to getlantern/lantern-ui by lanterndev 10 years ago
- Initial karma setup ping @akre54: view tests are really messed everything else looks good — committed to megawac/backbone by megawac 9 years ago
- can't run client side test,problem w karma&phantom Not only for me! https://github.com/karma-runner/karma/issues/558 — committed to aquincum/experigenserver2 by aquincum 8 years ago
Hey, all the people here: you are doing this so wrong!
The point is to test your app with Karma in real browsers, the one that your users use… unless you want your tests to have no value at all.
I solved this issue by reinstalling node_modules
@antonyh sounds awfully irrational though, sounds like Microsoft 😦 good software shouldn’t magically fix itself upon restart or reinstall.
How to configure karma_start.js to disable web security and local to remote url access using phantom launcher?
I solved this issue by deleting the
node_modulesfolder and runningnpm installagain - PhantomJS and Karma ran flawlessly following this cleanup.PhantomJS 2.1.1 on Linux Karma 1.2.0 Grunt 0.4.5
This issue accumulated a lot of different problems and is not actionable now. It has not been active for 2.5 years and PhantomJS has been archived two years ago. If you still experience issues with PhantomJS consider migrating to Chrome Headless or Firefox Headless.
If someone facing this problem in angular/cli, I’ve fixed this problem by uncommenting this lines in polyfill.ts: import ‘core-js/es6/symbol’; import ‘core-js/es6/object’; import ‘core-js/es6/function’; import ‘core-js/es6/parse-int’; import ‘core-js/es6/parse-float’; import ‘core-js/es6/number’; import ‘core-js/es6/math’; import ‘core-js/es6/string’; import ‘core-js/es6/date’; import ‘core-js/es6/array’; import ‘core-js/es6/regexp’; import ‘core-js/es6/map’; import ‘core-js/es6/weak-map’; import ‘core-js/es6/set’;
Hello everyone, I ran into this same (frustrating) issue and discovered the problem was in the karma config. Since I was using gulp to run karma / PhantomJS. When I changed singleRun: false -> true it started working for me again:
You can also change this parameter directly inside of the karma config as well:
The issue got resolved for me in Ubuntu 14.04 by deleting the
node_modulesdirectory from the project (which had been checked-in by someone else using a Macbook). I rannpm installagain and thenode_modulesdirectory was recreated. We have also added the ‘node_modules’ directory to.gitignore@pawelszymanski PhantomJS is great for unit testing javascript that is unlikely to behave differently between browsers. AngularJS controllers using Karma, for instance. For heavy DOM manipulation where different browsers may have varying behavior, PhantomJS isn’t a good fit. There is a use case for it, you’re just not seeing it. It’s ironic that you’re criticizing people for “doing it wrong” when you’re posting your personal opinions about a testing tool in a bug tracker. Talk about doing it wrong…
@pawelszymanski PhantomJS is is WebKit, and is just as much a browser as Safari and Chrome for the purposes of testing. The value is that it can be run headless on a server for automated testing. It isn’t necessarily the only form of testing that should be performed, but is helpful for catching regressions. The tests have plenty of value. Your comment on the other hand…