Book Image

Using Node.js for UI Testing

By : Pedro Teixeira
Book Image

Using Node.js for UI Testing

By: Pedro Teixeira

Overview of this book

<p>Automating tests for your user interfaces has always been the holy grail of programming. Now, using Zombie.js and Mocha you can create and quickly run your tests, allowing you to test even small changes. Increase your confidence in the code and minimize the number of times you have to use a real browser while you develop.</p> <p>"Using Node.js for UI Testing" is a quick and thorough guide on how to automatically test your web app, keeping it rock solid and bug-free. You will learn how to simulate complex user behaviour and verify that your application behaves correctly.</p> <p>You will create a web app in Node.js that uses complex user interactions and AJAX; by the end you will be able to fully test it from the command-line. Then you will start creating the user interface tests for this application using Mocha as a framework and Zombie.js as a headless browser.</p> <p>You will also create a complete test suite, module by module, testing simple and complex user interactions.</p>
Table of Contents (15 chapters)

Defining the requirements of our web app


Before we dive too much into the Zombie.js world, we need to create a target for our tests, that is, a web application that provides a to-do list. This is the set of top-level requirements for such an application:

  • A user can sign up for the service for which he should provide an e-mail address as username and a password. By providing the username and the password, the user can create an authenticated session that will identify him throughout further interactions.

  • The user can create a to-do item.

  • The user can view a list of to-dos.

  • The user can remove a to-do item.

To implement this application we will use Node.js, a platform for building networking applications in JavaScript that Zombie.js also uses. We'll also use Flatiron, a set of components that will help you in building a web application on top of Node.js.

Note

In the interest of keeping things simple, we're building our application in Node.js. However, Zombie.js is suitable for testing applications...