Casper.JS Assertions for Chai
Casper–Chai provides a set of custom assertions for use with CasperJS.
You get all the benefits of Chai to test with CasperJS.
It is an alternative to Casper's built-in Tester. Instead of using
Casper's Tester you can use (in this case with Mocha and Chai):
describe("my page", function () {
it("can be opened by Casper", function () {
casper.open("http://www.google.com")
casper.then(function () {
expect(casper.currentHTTPStatus).to.equal(200);
});
casper.then(function () {
expect("Google").to.matchTitle
});
});
});
Tests
More documentation and examples.
For even more examples, if you are cool with
CoffeeScript, check out the unit
tests.
Installation
Casper-Chai can be installed with npm using npm install casper-chai
, or
including
build/casper-chai.js
in a directory require
will find it.
Add extensions to Chai with:
casper_chai = require('casper-chai');
chai.use(casper_chai);
To build locally, clone the project and run cake toast test
in the
project directory. You may have to run npm install
to get dependencies
(which, obviously, requires npm to be installed), and make sure cake
is
available - which should be possible by running npm install -g coffee-script
.
AMD
Casper–Chai supports being used as an AMD module, registering itself
anonymously (just like Chai).