Use your business data to your advantage with the help of Syncfusion’s new data science offerings. Discover how a custom big data solution can provide your company with valuable predictions about key market trends.

Using Node.js for UI Testing

Learn how to easily automate testing of your web apps using Node.js, Zombie.js, and Mocha

$14.99

$29.99

RRP $14.99

RRP $29.99

eBook

Print + eBook

Want this title & more?

$21.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781782160526

Paperback146 pages

About This Book

Use automated tests to keep your web app rock solid and bug-free while you code

Use a headless browser to quickly test your web application every time you make a small change to it

Use Mocha to describe and test the capabilities of your web app

Who This Book Is For

This book is for frontend and backend web application developers that know how to program in JavaScript.

Table of Contents

Chapter 1: Getting Started with Zombie.js

A brief history of software and user interface testing

Understanding the server-side DOM

Summary

Chapter 2: Creating a Simple Web App

Defining the requirements of our web app

Setting up Node.js and Flatiron

Creating your to-do app

File summary

Summary

Chapter 3: Installing Zombie.js and Mocha

Changing the application manifest

Setting up a test environment

Summary

Chapter 4: Understanding Mocha

Organizing your tests

Using before and after hooks

Using asynchronous hooks

Using assertions

Performing asynchronous tests

Summary

Chapter 5: Manipulating the Zombie Browser

When is the browser ready?

Checking the existence of elements

Filling a form

Testing the login form

Testing the to-do list

Putting it all together

Summary

Chapter 6: Testing Interactions

Acting on radio buttons

Testing the user interaction

Selecting values

Summary

Chapter 7: Debugging

Running a specific test

Using the browser JavaScript console

Dumping the browser state

Dumping the whole document

Summary

Chapter 8: Testing AJAX

Implementing drag-and-drop

Summary

What You Will Learn

Creating your test suite using Mocha

Building a web application using Node.js and Flatiron.js

Loading documents into the Zombie.js headless browser

Triggering user events in Zombie.js

Querying the DOM to test your application behaviour

Injecting complex events into your application

Triggering and testing complex user interactions and AJAX calls

Inspecting the Zombie headless browser state

In Detail

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.

"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.

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.

You will also create a complete test suite, module by module, testing simple and complex user interactions.

Authors

Pedro Teixeira

Pedro Teixeira is a prolific open source programmer and author of many Node.js modules. After he graduated as a software engineer over 14 years ago, he has been a consultant, a programmer, and an active and internationally known Node.js community member.

He is a founding partner of The Node Firm (a consulting company specializing in Node.js) and author of the popular Node Tuts screencasts (www.nodetuts.com) and three other books about Node.js, namely, Hands-on Node.js (self-published), Professional Node.js, Wrox, and Node.js for UI Testing, Packt Publishing.

When he was ten years old, his father taught him how to program a ZX Spectrum, and since then, he never wanted to stop. He taught himself how to program his father's Apple IIc and then entered the PC era. During college, he was introduced to the universe of Unix and open source, becoming seriously addicted to it. In his professional life, he has developed systems and products with Visual Basic, C, C++, Java, PHP, Ruby, and JavaScript for big Telco companies, banks, hotel chains, and others.

He has been a Node.js enthusiast since the very beginning, having authored many applications and also many well-known modules, such as Fugue, Alfred.js, Carrier, Nock, and others.

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.