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)

Creating your to-do app


Now that you have a Flatiron "hello world" example running, you need to extend it so that our to-do application takes shape. For this you will need to create and change some files. If you ever get lost, you can always refer to the chapter's source code. Also, for your reference, there is a complete list of the project files included at the end of this chapter.

Setting up the database

As in any real application, you will need a reliable way to persist data. Here we will use CouchDB, the open-source and document-oriented database. You can either choose to install CouchDB locally or use a service over the Internet, such as Iris Couch.

If you choose to install CouchDB on your local development machine, you can head out and visit http://couchdb.apache.org/, click on Download and follow the instructions.

If you prefer to simply use CouchDB over the Internet, you can head out to http://www.iriscouch.com/, click on the Sign Up Now button and fill the registration form. You should...