Using Node.js for UI Testing

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

Using Node.js for UI Testing

Starting
Pedro Teixeira

Learn how to easily automate testing of your web apps using Node.js, Zombie.js, and Mocha
$10.00
$29.99
RRP $14.99
RRP $29.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 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.

+ Collection
Free Sample

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

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

Book Details

ISBN 139781782160526
Paperback146 pages
Read More