Using Node.js for UI Testing

Using Node.js for UI Testing
eBook: $14.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $44.98    Print cover: $29.99
save 5%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • 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

Book Details

Language : English
Paperback : 146 pages [ 235mm x 191mm ]
Release Date : March 2013
ISBN : 1782160523
ISBN 13 : 9781782160526
Author(s) : Pedro Teixeira
Topics and Technologies : All Books, Web Development, Open Source, Web Development

Table of Contents

Chapter 1: Getting Started with Zombie.js
Chapter 2: Creating a Simple Web App
Chapter 3: Installing Zombie.js and Mocha
Chapter 4: Understanding Mocha
Chapter 5: Manipulating the Zombie Browser
Chapter 6: Testing Interactions
Chapter 7: Debugging
Chapter 8: Testing AJAX
  • Chapter 1: Getting Started with Zombie.js
    • A brief history of software and user interface testing
      • Enter the automation era
      • Unit tests versus integration tests
      • What Zombie.js is
    • Understanding the server-side DOM
      • Zombie.js is your headless browser
    • Summary
    • Chapter 2: Creating a Simple Web App
      • Defining the requirements of our web app
      • Setting up Node.js and Flatiron
        • Installing Node.js
          • Installing Node from the source code
        • Installing Flatiron and starting your application
      • Creating your to-do app
        • Setting up the database
        • Accessing CouchDB from Node
        • Application layout
        • Developing the frontend
        • User registration
        • Logging in and session management
        • The to-do list
      • File summary
      • Summary
        • Chapter 4: Understanding Mocha
          • Organizing your tests
          • Using before and after hooks
          • Using asynchronous hooks
            • How hooks interact with test groups
          • Using assertions
            • Changing the assertion message
          • Performing asynchronous tests
          • Summary
          • Chapter 5: Manipulating the Zombie Browser
            • When is the browser ready?
              • Options when visiting URLs
                • debug
                • headers
                • maxWait
            • Checking the existence of elements
            • Filling a form
            • Testing the login form
            • Testing the to-do list
              • Testing the to-do list page
              • Testing the to-do item creation
              • Testing to-do item removal
            • Putting it all together
            • Summary
              • Chapter 7: Debugging
                • Running a specific test
                  • Enabling the debugging output per test
                • Using the browser JavaScript console
                • Dumping the browser state
                • Dumping the whole document
                • Summary

                  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.

                  Code Downloads

                  Download the code and support files for this book.

                  Submit Errata

                  Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

                  Sorry, there are currently no downloads available for this title.

                  Frequently bought together

                  Using Node.js for UI Testing +    Mastering Object-oriented Python =
                  50% Off
                  the second eBook
                  Price for both: $30.45

                  Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                  What you will learn from this book

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


                  Full of techniques and tips for simulating user interactions and verifying that your application is behaving correctly.

                  Who this book is for

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

                  Code Download and Errata
                  Packt Anytime, Anywhere
                  Register Books
                  Print Upgrades
                  eBook Downloads
                  Video Support
                  Contact Us
                  Awards Voting Nominations Previous Winners
                  Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                  Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software