Trouble capturing Phantomjs via Karma when testing on a hosted agent
See original GitHub issueI’m trying to use a VSTS hosted agent to build my web app and run Jasmine tests through Karma. I’m using NPM to launch Karma using the task:
"test": "karma start --reporters mocha,junit --single-run --browsers PhantomJS",
I’m able to build my web app just fine, but Karma runs into issues trying to start the PhantomJS headless browser to run my tests. I’m seeing these messages in the logs:
2016-04-04T22:54:15.0148818Z [command]C:\Program Files\nodejs\npm.cmd run test
2016-04-04T22:54:15.9338829Z > myapp@0.1.0 test C:\a\1\s
2016-04-04T22:54:15.9338829Z > karma start --reporters mocha,junit --single-run --browsers PhantomJS
2016-04-04T22:54:19.0078825Z START:
2016-04-04T22:54:35.1438831Z ts-loader: Using typescript@1.8.9 and C:\a\1\s\test\tsconfig.json
2016-04-04T22:54:42.3838827Z 04 04 2016 22:54:42.380:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
2016-04-04T22:54:42.3958835Z 04 04 2016 22:54:42.393:INFO [launcher]: Starting browser PhantomJS
2016-04-04T22:57:42.3970982Z 04 04 2016 22:57:42.396:WARN [launcher]: PhantomJS have not captured in 180000 ms, killing.
2016-04-04T22:57:44.4000982Z 04 04 2016 22:57:44.399:WARN [launcher]: PhantomJS was not killed in 2000 ms, sending SIGKILL.
2016-04-04T22:57:46.4000995Z 04 04 2016 22:57:46.399:WARN [launcher]: PhantomJS was not killed by SIGKILL in 2000 ms, continuing.
2016-04-04T22:57:46.4090997Z Finished in 0 secs / 0 secs
2016-04-04T22:57:46.6030998Z npm ERR! Windows_NT 6.3.9600
2016-04-04T22:57:46.6040993Z npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
2016-04-04T22:57:46.6040993Z npm ERR! node v0.12.7
2016-04-04T22:57:46.6050995Z npm ERR! npm v2.11.3
2016-04-04T22:57:46.6050995Z npm ERR! code ELIFECYCLE
2016-04-04T22:57:46.6060993Z npm ERR! myapp@0.1.0 test: `karma start --reporters mocha,junit --single-run --browsers PhantomJS`
2016-04-04T22:57:46.6060993Z npm ERR! Exit status 1
2016-04-04T22:57:46.6060993Z npm ERR!
2016-04-04T22:57:46.6070995Z npm ERR! Failed at the myapp@0.1.0 test script 'karma start --reporters mocha,junit --single-run --browsers PhantomJS'.
2016-04-04T22:57:46.6070995Z npm ERR! This is most likely a problem with the myapp package,
2016-04-04T22:57:46.6080994Z npm ERR! not with npm itself.
2016-04-04T22:57:46.6080994Z npm ERR! Tell the author that this fails on your system:
2016-04-04T22:57:46.6080994Z npm ERR! karma start --reporters mocha,junit --single-run --browsers PhantomJS
2016-04-04T22:57:46.6090992Z npm ERR! You can get their info via:
2016-04-04T22:57:46.6090992Z npm ERR! npm owner ls myapp
2016-04-04T22:57:46.6100992Z npm ERR! There is likely additional logging output above.
2016-04-04T22:57:46.6100992Z npm ERR! Please include the following file with any support request:
2016-04-04T22:57:46.6100992Z npm ERR! C:\a\1\s\npm-debug.log
2016-04-04T22:57:46.6230995Z ##[debug]rc:1
2016-04-04T22:57:46.6240986Z ##[debug]success:false
2016-04-04T22:57:46.6250991Z ##[debug]taskRunner fail
2016-04-04T22:57:46.6270971Z ##[debug]task result: Failed
2016-04-04T22:57:46.6330990Z Npm failed with error: C:\Program Files\nodejs\npm.cmd failed with return code: 1
I’m able to run this just fine on my Windows machine. I tried increasing the capture timeout in case it wasn’t starting up within 60 seconds, but it still doesn’t work with a timeout of 180 seconds. Could it be because I can’t connect to http://localhost:9876/ with PhantomJS? Also, I’m not sure why Karma’s not able to kill the process.
Is there a technique or workaround to get PhantomJS to launch properly and connect to Karma on a hosted agent?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:13 (3 by maintainers)
Top GitHub Comments
@ntziolis I was coming across the same issue and was able to resolve it by changing from “Hosted” to “Hosted VS2017” agent in the Options tab of my builds. Not sure if that’s an option for you but something seems to have changed on the default Hosted agents that Microsoft is spinning up for us
In case anyone else lands here, the fix I found via stackoverflow is to add a build variable with the key “PHANTOMJS_BIN” and the value “C:\NPM\Modules\PhantomJS.cmd”.