Examples of using CasperJS for end-to-end testing where we load Google and do a search, then we test if we are on the right results page and did we get enough results.
Requires PhantomJS to be installed. You can check it by typing phantomjs -v
in your terminal.
Run npm install
on this project's root folder
You have 2 different ways of testing:
- Pure CasperJS way by running
casperjs test with-pure-casper.coffee
- CasperJS with Mocha & Chai via CasperJS Mocha plugin by running
mocha-casperjs with-casper-mocha-chai.coffee
Also for the sake of example, both CoffeeScript and vanilla JavaScript versions are provided.
To integrate these end-to-end tests with Jenkins we use XUnit XML files.
For pure CasperJS, use:
casperjs test with-pure-casper.coffee --xunit=xunit.xml
For CasperJS with Mocha plugin, use:
mocha-casperjs --reporter=xunit with-casper-mocha-chai.coffee > xunit.xml