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

Introduction


Business logic for a single view can be found in a controller. Controllers are used for configuring the initial $scope object or adding behavior to $scope. DOM manipulation, however, should not be managed within controllers. For further information regarding AngularJS controllers, please read the online documentation at https://docs.angularjs.org/guide/controller. Considering what we've just discussed, tests should be focused either on modifications to the scope object or its associated behavior. A scope can be an assigned initial property that provides the view with data. These properties are then updated either via user interaction or from external services. Scope behavior is constructed by attaching methods to the scope object. This chapter will focus on how to set up a test for testing a controller and pay particular attention to the tasks we would expect to be handled within a controller.