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)

Setting up Node.js and Flatiron


If you don't have the latest version of Node.js installed, you will need to install it. You will need Node.js for several reasons. Our web application will use Flatiron, which runs on top of Node.js. You will also need to use the Node Package Manager (NPM), which comes bundled with Node. Finally, you will need Node.js to install and run your Zombie.js tests.

Installing Node.js

  1. To install Node.js head out to the nodejs.org website.

  2. Then click on the Download button, which should open the following page:

  3. If you're running a Windows or a Macintosh system, click on the respective installer icon. That should download and start up the graphical installer.

Installing Node from the source code

If you're not running one of these systems and you are on a Unix-like system, you can install Node.js from the source code by following these steps:

  1. Click on the source code icon, which will start downloading the source code tarball. Once downloaded, expand it using the terminal:

    $...