Grunt and PhantomJS, sitting in a tree.
WARNING: This is an unoffical fork that works with PhantomJS version 2.0.0. It was created because the upgrade to the desired
version of PhantomJS has not yet been done for the master branch of
The best way to understand how this lib should be used is by looking at the grunt-contrib-qunit plugin. Mainly, look at how the lib is required, how event handlers are bound and how PhantomJS is actually spawned.
Also, in the case of the grunt-contrib-qunit plugin, it's important to know that the page being loaded into PhantomJS doesn't know it will be loaded into PhantomJS, and as such doesn't have any PhantomJS->Grunt code in it. That communication code, aka. the "bridge", is dynamically injected into the html page.
timeout: PhantomJS' timeout, in milliseconds.
page: an object of options for the PhantomJS
screenshot: saves a screenshot on failure
An inline example
If a Grunt task looked something like this:
test.html looked something like this (note the "bridge" is hard-coded into this page and not injected):
Then running Grunt would behave something like this:
$ grunt mytaskRunning "mytask" taskSomething worked.>> Something failed.Warning: Task "mytask" failed. Use --force to continue.Aborted due to warnings.
PhantomJS requires these dependencies on Ubuntu/Debian:
apt-get install libfontconfig1 fontconfig libfontconfig1-dev libfreetype6-dev