Testing user registration
Let's use the setup built in the previous sections and write an actual test. Let's say that we want to make sure that our registering page works. The following are the two processes that we want to capture with our test:
Filling the form with wrong data and making sure that the application shows an error message
Filling the form with correct data and seeing a successful message
We are going to use PhantomJS as our headless (virtual) browser. So, all we have to do is load our registration page and simulate user interactions, such as typing in the fields and pressing the buttons.
Simulating user interaction
There are a couple of issues that we are going to resolve. The first one is the actual simulation of user actions. From a JavaScript point of view, these actions are translated to events dispatched by some particular DOM elements. The following helper method will become a part of the tests/spec.js
file:
describe("Testing", function () { var trigger = function(element...