Let’s Use a Page Object

The integration tests were not really that complicated, but they can get cumbersome if we’re not careful. There are four major problems in the integration tests we wrote:

  1. Noisy: The code to access the elements and to verify the contents is noisy. Less noise would result in easier-to-maintain tests.

  2. Duplication: The code to get an element, like tasks or message, for example, is duplicated throughout the tests. Less duplication would mean fewer errors and make it easier to deal with changes to the pages.

  3. Tight coupling on page implementation: Suppose, for whatever reason, the span element that displays the tasks count is changed to have a class instead of an id. All the tests that use this element will have to change—this ...

Get Test-Driving JavaScript Applications 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.