Book Image

AngularJS Web application development Cookbook

By : Matthew Frisbie
Book Image

AngularJS Web application development Cookbook

By: Matthew Frisbie

Overview of this book

Packed with easy-to-follow recipes, this practical guide will show you how to unleash the full might of the AngularJS framework. Skip straight to practical solutions and quick, functional answers to your problems without hand-holding or slogging through the basics. Avoid antipatterns and pitfalls, and squeeze the maximum amount out of the most powerful parts of the framework, from creating promise-driven applications to building an extensible event bus. Throughout, take advantage of a clear problem-solving approach that offers code samples and explanations of components you should be using in your production applications.
Table of Contents (17 chapters)
AngularJS Web Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the Page Object test pattern


Creating and maintaining a test suite for an application is a considerable amount of overhead, and a prudent developer will mold a test suite such that the normal evolution of a software application will not force developers to spend an unduly long amount of time to maintain the test code.

A surprisingly sensible design pattern called the Page Object pattern encapsulates segments of the page-specific user experience and abstracts it away from the logic of the actual tests.

How to do it…

The test/e2e/signup_flow_test.js file presented in the Writing basic E2E tests recipe can be refactored into the following files using the Page Object pattern.

The test/pages/main.js file can be refactored as follows:

(test/pages/main.js)

var MainPage = function () {
  // direct the browser when the page object is initialized
  browser.get('/');
};

MainPage.prototype = Object.create({},
  {
    // getter for element in page
    signupLink: {
      get: function() {
       ...