You are previewing Using Node.js for UI Testing.
O'Reilly logo
Using Node.js for UI Testing

Book Description

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

  • 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

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.

Table of Contents

  1. Using Node.js for UI Testing
    1. Table of Contents
    2. Using Node.js for UI Testing
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Getting Started with Zombie.js
      1. A brief history of software and user interface testing
        1. Enter the automation era
        2. Unit tests versus integration tests
        3. What Zombie.js is
      2. Understanding the server-side DOM
        1. Zombie.js is your headless browser
      3. Summary
    9. 2. Creating a Simple Web App
      1. Defining the requirements of our web app
      2. Setting up Node.js and Flatiron
        1. Installing Node.js
          1. Installing Node from the source code
        2. Installing Flatiron and starting your application
      3. Creating your to-do app
        1. Setting up the database
        2. Accessing CouchDB from Node
        3. Application layout
        4. Developing the frontend
        5. User registration
        6. Logging in and session management
        7. The to-do list
      4. File summary
      5. Summary
    10. 3. Installing Zombie.js and Mocha
      1. Changing the application manifest
      2. Setting up a test environment
      3. Summary
    11. 4. Understanding Mocha
      1. Organizing your tests
      2. Using before and after hooks
      3. Using asynchronous hooks
        1. How hooks interact with test groups
      4. Using assertions
        1. Changing the assertion message
      5. Performing asynchronous tests
      6. Summary
    12. 5. Manipulating the Zombie Browser
      1. When is the browser ready?
        1. Options when visiting URLs
          1. debug
          2. headers
          3. maxWait
      2. Checking the existence of elements
      3. Filling a form
      4. Testing the login form
      5. Testing the to-do list
        1. Testing the to-do list page
        2. Testing the to-do item creation
        3. Testing to-do item removal
      6. Putting it all together
      7. Summary
    13. 6. Testing Interactions
      1. Acting on radio buttons
      2. Testing the user interaction
      3. Selecting values
      4. Summary
    14. 7. Debugging
      1. Running a specific test
        1. Enabling the debugging output per test
      2. Using the browser JavaScript console
      3. Dumping the browser state
      4. Dumping the whole document
      5. Summary
    15. 8. Testing AJAX
      1. Implementing drag-and-drop
      2. Summary
    16. Index