Skip to content

Using Intern with PhantomJS

csnover edited this page Nov 20, 2014 · 15 revisions

PhantomJS is not a suitable replacement for testing in real browsers. Do not use PhantomJS unless you are aware of the caveats of testing against fake browsers like PhantomJS. If don’t know these caveats, and just want a headless browser for testing, install xvfb and ChromeDriver and use xvfb-run -s "-screen 0 1280x1024x24" ./chromedriver to test using a real copy of Chrome.

Using a local PhantomJS installation with Intern is very simple:

  1. In your Intern configuration, set environments: [ { browserName: 'phantomjs' } ] and tunnel: 'NullTunnel'
  2. Ensure that the directory containing the phantomjs executable is in your PATH (this will typically be the case if you installed with npm install -g phantomjs)
  3. Start your local Selenium server (java -jar selenium-server-standalone-2.xx.x.jar)
  4. Run intern-runner config=path/to/config

Note that PhantomJS must be used with Selenium server. PhantomJS’s built-in WebDriver server violates the HTTP specification (at least up to PhantomJS 1.9.8), which prevents Intern from communicating with it directly.

Clone this wiki locally