Using Node.js for UI Testing

More Information
  • 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

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.

  • 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
Page Count 146
Course Length 4 hours 22 minutes
ISBN 9781782160526
Date Of Publication 26 Mar 2013


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

He's the organizer of LXJS— the Lisbon JavaScript Conference.