Generically, the purpose of performing end-to-end testing is to "identify system dependencies and to ensure that data integrity is maintained between various system components"
This differs from unit testing in that you are testing the whole system instead of small functional units.
$ npm install -g phantomjs
$ npm install -g casperjs
$ casperjs --version && phantomjs --version
Before we dive into the testing framework, let's take phantom.js for a spin using casper.js to drive it!
We're going to take a look at a simple script that visits www.ncaa.com homepage and then navigates to a scoreboard page.
Casper has the ability to execute arbitrary JS code against the remote page's JS thread. It works like this:
Notice the "return native types" arrow. This allows you to get data back from the remote page and use it for whatever you want in your casper script!
Casper wouldn't be complete if it didn't
have the ability to fill out and submit forms. Of course, you can also
react to whatever the result of that
submission is using the various wait
functions.
Let's try logging in as an editor on the
NCAA QA server and then seeing if we
can get to the "create article" page.
One of the cooler aspects of Casper is that it can take full-page screenshots of whatever the remote page looks like at various moments along the way.
You can also use CSS selectors to capture screens of various page regions (this is feature is kind of buggy though depending on how you CSS position the element you want to capture)
assertExists / assertDoesntExist
assertVisible / assertNotVisible
assertElementCount(selector, count)
assertTitle(text) / assertTitleMatch(regex)
If you want a copy of the code used in this presentation: http://www.github.com/mattacular/casper-demo