PhantomJS unit testing module installable through npm.
Makes your PhantomJS javascript spaghetti testable, reusable and maybe even production-ready.
phantomjs-test-provisions uses a standalone version of Jasmine. This package is largely based off of code in the upstream PhantomJS repository. As a separate node module, it's a quick option for developers interested in adding testing to their PhantomJS outer context (JavaScriptCore environment).
Note that PhantomJS must be installed. It must be available in $PATH
.
With npm do:
npm install phantomjs-test-provisions
This adds unit testing to PhantomJS modules. To make use of the global script, use:
npm install -g phantomjs-test-provisions
Write tests in tests/spectacles.js
like this:
exports.run = function() {
describe("phantomjs-test-provisions example test", function() {
var mymodule = require("./../../mymodule");
it("should exist", function() {
should.exist(mymodule);
});
});
}
Then run tests like this (if it was installed through npm install -g
):
phantomjs-test
Using the script through a relative path is also possible and it could be added
to a Gruntfile
or package.json
like so:
./node_modules/phantomjs-test-provisions/bin/phantomjs-test
There are multiple styles available, provided by Chai including assert and expect/should.
There is also a default example which can run immediately for this project:
npm test
Also there is an example using grunt (see Gruntfile.js
):
grunt test
or even:
./bin/phantomjs-test
BSD