Book Image

AngularJS Testing Cookbook

By : Simon Bailey
Book Image

AngularJS Testing Cookbook

By: Simon Bailey

Overview of this book

<p>AngularJS stepped up to offer a comprehensive solution to frontend development with minimal dependencies and a clear set of objectives.</p> <p>This book follows the AngularJS philosophy and offers guidance on how to approach testing components that make up the AngularJS framework. At the start of the book, you will explore how to configure your system to run unit and end-to-end tests. Following this, you'll become familiar with fundamental principles on testing AngularJS with Jasmine. Then, you'll understand how spies can enable you to test your code with greater coverage and simplicity throughout your application. The final result is an AngularJS application that is tested with integrity, helping facilitate a cleaner and more reliable codebase.</p>
Table of Contents (16 chapters)
AngularJS Testing Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Testing navigation using Protractor


When testing navigation, it would be great to actually load and navigate through states within a browser. Luckily, we can do just that using Protractor. This is quite compelling, because, typically, to test interactive route changes we would expect a manual process whereby a user would have to load the page in a browser and interact with elements, for example clicking a button to trigger a route/state change. We can configure Protractor to follow a defined set of instructions and mimic user actions thereby saving a lot of our time and effort plus enabling a greater spectrum of application testing. In this recipe, we will test navigation through an AngularJS application based on element interaction using Protractor.

Getting ready

For this recipe, we can build on the steps from the Getting ready section from the Testing URL parameters with ui-router recipe in this chapter. This will provide us with a default home state and the emcees state to transition to...