0.0.12 • Published 11 years ago

phantomjs-test-provisions v0.0.12

Weekly downloads
17
License
-
Repository
github
Last release
11 years ago

phantomjs-test-provisions

PhantomJS unit testing module installable through npm. Makes your PhantomJS javascript spaghetti testable, reusable and maybe even production-ready.

Note that PhantomJS must be installed. It is not a directly stated dependency because many developers choose to install phantomjs separately (outside of node/npm), and an explicit dependency on PhantomJS would entail downloading an additional copy of the PhantomJS binary.

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 could be a quick option for developers interested in adding testing to their PhantomJS outer context (JavaScriptCore environment).

install

With npm do:

npm install phantomjs-test-provisions

usage

There is a default example which can run immediately:

npm test

Also there is an example using grunt (see Gruntfile.js):

grunt test

To add tests to a separate PhantomJS module, add a tests/run-tests.js that looks like this:

// load and setup phantomjs-test-provisions
var testprovisions = require("./../node_modules/phantomjs-test-provisions");
var jasmine = testprovisions.jasmine;
var jasmineConsoleReporter = testprovisions.jasmineConsoleReporter;
var chai = testprovisions.chai;
var should = chai.should();
var it = jasmine.it;
var describe = jasmine.describe;

/* Remember to setup the module if it's expected to be available later. It
could also be required() inside each individual test. */
var mymodule = require("./../../mymodule")

// include the custom test files here
phantom.injectJs("./test-sample.js");

// launch the tests
var jasmineEnv = testprovisions.configureJasmine();
jasmineEnv.execute();

Then write tests in tests/test-sample.js like:

describe("phantomjs-test-provisions example test", function() {
    it("should exist", function() {
        should.exist(mymodule);
    });
});

license

BSD

0.0.12

11 years ago

0.0.11

11 years ago

0.0.10

11 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago