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)

Chapter 5. Manipulating the Zombie Browser

Now that we have our to-do HTTP application and understand how the Mocha testing framework works, we are ready to start creating tests using Zombie.js.

As covered before, Zombie.js allows you to create a simulated browser environment and manipulate it. These manipulations are the usual things users do with browsers, such as visiting a URL, clicking on links, filling and submitting forms, and others.

This chapter covers the following:

  • Visiting a URL

  • Filling and submitting a form

  • Checking for errors in the browser

  • Validating document content

  • Understanding CSS selector syntax

This chapter shows you how you can setup a Zombie.js browser that interacts with your web application.

Visiting a URL: First, we are going to pick up our application tests from where we left off. The whole app concerns users, but in this part, we're mainly going to focus on functionality that the Users routes touch—rendering a signup form and actually creating a user record in the database...