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) ...
Get AngularJS Web Application Development Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.