Book Image

Angular Test-Driven Development - Second Edition

By : Md. Ziaul Haq
Book Image

Angular Test-Driven Development - Second Edition

By: Md. Ziaul Haq

Overview of this book

<p>This is a complete guide that shows you testing techniques with Karma that will help you perform unit testing and end-to-end testing with Protractor. It will show you how to optimize your Angular development process using TDD techniques and ensure your final project is free of bugs. All examples in this book are based on Angular v2 and are compatible with Angular v4.</p> <p>We start by reviewing the TDD life cycle, TDD in the context of JavaScript, and various JavaScript test tools and frameworks. You will see how Karma and Protractor can make your life easier while running JavaScript unit tests. We will enable you to build a test suite for an Angular application and build a testable medium-to-large scale Angular application by handling REST API data.</p> <p>Building on the initial foundational aspects, we move on to testing for multiple classes, partial views, location references, CSS, and the HTML element. In addition, we will explore how to use a headless browser with Karma. We will also configure a Karma file to automate the testing and tackle elements of Angular (components, services, classes, and broadcasting) using TDD.</p> <p>Finally, you will find out how to pull data using an external API, set up and configure Protractor to use a standalone Selenium server, and set up Travis CI and Karma to test your application.</p>
Table of Contents (15 chapters)
Angular Test-Driven Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Origins of Protractor


Protractor is not the first end-to-end testing tool that the Angular team built. The first tool was called Scenario Runner. In order to understand why Protractor was built, we need to first look at its predecessor--Scenario Runner.

Scenario Runner is in the maintenance mode and has reached the end of its life. It has been deprecated in the place of Protractor. In this section, we will look at what Scenario Runner was and what gaps the tool had.

The birth of Protractor

Julie Ralph is the primary contributor of Protractor. According to Julie Ralph, the motivation for Protractor was based on the following experience with the Angular Scenario Runner on another project within Google (http://javascriptjabber.com/106-jsj-protractor-with-julie-ralph/):

"We tried using the Scenario Runner. And we found that it really just couldn't do the things that we needed to test. We needed to test things like logging in. Your login page isn't an Angular page, and the Scenario Runner couldn...