Alex Vayda
Alex Vayda

Reputation: 6494

Karma + PhantomJS + no internet access

I need to run Karma tests using PhantomJS on a continuous integration server with no internet access. Every build starts from running npm install --no-registry and then grunt Grunt Karma is configured for single run (singleRun: true)

Everything works well except PhantomJS. Even though phantomjs package is in npm-cache it tries to download actual binary (.exe in my case) directly from bitbucket.org and obviously fails due to no inet access.

I tried to pre-install PhantomJS package globally (npm install -g phantomjs). Now the binary is resolved in offline mode, tests run pass and pass, everything looks fine but... Karma test suite now never ends (presumably due to PhantomJS never exits) until I hit Ctrl+C. (It only happens when I explicitly install PhantomJS package globally with npm install -g .... If I'm not doing that and let it to be downloaded from the BitBucket automatically it run fine). The version of PhantomJS is the same in both cases, I double checked.

I tried different versions of PhantomJS (1.9.7, 1.9.6, 1.9.2) and Karma (0.11, 0.10) -- no difference.

Here's my package.json:

"devDependencies": {
    "grunt": "~0.4",
    "karma": "~0.10",
    "grunt-karma": "~0.6"
}

And here's what I see if I run Karma having PhantomJS installed with '-g':

> npm install -g phantomjs
Done. Phantomjs binary available at .....
[email protected] C:\Users\.....\npm\node_modules\phantomjs

> karma start --single-run
INFO [karma]: Karma v0.10.9 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket JjD-wPAWrUeuz1NBTw02
LOG: 'JQMIGRATE: Logging is active'
PhantomJS 1.9.7 (Windows 7): Executed 60 of 60 SUCCESS (0.362 secs / 0.204 secs)
WARN [launcher]: PhantomJS was not killed in 2000 ms, sending SIGKILL.
_

(and hangs... After Ctrl+C build is continued)

I don't get why this is happening.

Questions

Thank you!

Upvotes: 2

Views: 1756

Answers (1)

Alastair Maw
Alastair Maw

Reputation: 5492

According to the PhantomJS NPM package documentation you can set the PHANTOMJS_CDNURL environment variable to point to a different (local) HTTP endpoint when you run npm install.

PHANTOMJS_CDNURL=http://some.server.here/downloads npm install phantomjs

The default is https://bitbucket.org/ariya/phantomjs/downloads.

Also, if you put PhantomJS on your path, it should try to use that.

Upvotes: 2

Related Questions