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)

Organizing your tests


There are two strategies you can use to organize your tests. The first is to divide them somehow into separate files, each file representing a functional or logical unit of your application. The other strategy, which can be used in tandem with the first one, is to group them by feature.

Having a separate file for each functional unit of your app is a good way of separating your testing concerns. You should analyze the structure of your application and separate it into distinct concerns that have a minimum amount of overlap. For instance, your application may have to deal with user registrations—that could be one functional group. Another functional group may be user login. If your application deals with to-do lists, you may want to have a separate file that contains the tests for that part of your application.

By having separate files for each functional group, you can call your tests in isolation while you're working on that particular group. This technique also allows...