Book Image

AngularJS Test-driven Development

By : Tim Chaplin
Book Image

AngularJS Test-driven Development

By: Tim Chaplin

Overview of this book

<p>Starting with reviewing the test-driven development (TDD) life cycle, you will learn how Karma and Protractor make your life easier while running JavaScript unit tests. You will learn how Protractor is different from Selenium and how to test it entirely. This book is a walk-through to using TDD to build an AngularJS application containing a controller, model, and scope.</p> <p>Building on the initial foundational aspects, you will expand to include testing for multiple controllers, partial views, location references, CSS, and the HTML element. In addition, you will explore using a headless browser with Karma. You will also configure Karma file watching to automate testing and tackle components of AngularJS (controller, service, model, and broadcasting) using TDD. At the end of this book, you will extend explore how to pull data using an external API, setting up and configuring Protractor to use a standalone Selenium server, and setting up Travis CI and Karma to test your application.</p> <p>This book is a complete guide to testing techniques using Karma for unit testing and performing end-to-end testing with Protractor.</p>
Table of Contents (17 chapters)
AngularJS Test-driven Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Appendix A. Integrating Selenium Server with Protractor

Throughout this book, we used Selenium ChromeDriver to test with Protractor. What this meant was that in order to run a Protractor test, we simply had to have the website running and then kick off Protractor. In Chapter 3, End-to-end Testing with Protractor, ChromeDriver was installed and used to run the tests. From the perspective of the book and TDD, this was acceptable. Our tests were small and contained and did not have a lot of moving parts.

The problem with only using ChromeDriver is that we can't test on other browsers. As your application grows and you want to support more browsers, you need to think about running a standalone Selenium Server. This section of the book provides a walk-through of how to get a standalone Selenium Server running and integrated with Protractor.