One major use case of PhantomJS is headless testing of web applications. It is suitable for general command-line based testing, within a precommit hook, and as part of a continuous integration system.
PhantomJS itself is not a test framework, it is only used to launch the tests via a suitable test runner.
The following table summarizes the list of various test frameworks and the corresponding test runners. If the framework does not need an external/third-party runner, it is marked as “built-in”.
|Karma (née Testacular)||built-in|
|Jasmine||Chutzpah, grunt-contrib-jasmine, guard-jasmine, phantom-jasmine|
|QUnit||qunit-phantomjs-runner, Chutzpah, JS Test Runner, Qlive, QUnited|
|Rx Test Runner||built-in|
PhantomJS tailored testing
In addition, there are Related Projects which are built on top of PhantomJS to provide convenient high-level functionality for testing purposes:
- Casper.js is useful to build scripted navigation and testing
- Lotte adds jQuery-like methods, chaining, and more assertion logic
- WebSpecter is a BDD-style acceptance test framework for web applications
Continuous Integration Systems
Since PhantomJS is purely headless on Linux, the agent can run on an installation without any GUI. This means, a barebone Linux system without X11 is not a problem for PhantomJS. It makes it possible to spawn light build agents on Amazon EC2 or Heroku instances.