-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Headless Testing
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 as 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 test frameworks have built-in support for PhantomJS.
For other test frameworks, various test runners/drivers are usually available:
In addition, there are 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
PhantomJS includes run-qunit and run-jasmine in its examples
subdirectory. However, these are for illustration purposes, it lacks important reporting features necessary for real-world uses.
Using PhantomJS with CI system such as Jenkins or TeamCity does not require special setup. Make sure PhantomJS is installed properly on the slave/build agent and it is ready to go.
Since PhantomJS is purely headless on Linux, the agent can run on an installation with 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.
Travis CI, a popular hosted CI system, has built-in support for PhantomJS. See its documentation for details.