Skip to content

Using Intern with PhantomJS

jason0x43 edited this page Nov 7, 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.

While PhantomJS is not a suitable replacement for testing in real browsers, it is often quicker and easier to test with PhantomJS when writing your tests and then let your CI service handle running tests across all platforms.

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
  3. Start your local Selenium server
  4. Run intern-runner config=path/to/config

Note that PhantomJS must be used through Selenium. PhantomJS may be run as a standalone web server with its --webdriver command line option, but there is a bug in its webdriver server implementation (at least up to PhantomJS 1.9.8) that prevents Intern from communicating with it directly.