cypress-page-object

2022.
#development#open-source #typescript#node-js#cypress

Cypress is an automation testing framework with great support for handling comprehensive tests against frontend applications. One way to manage a frontend test suite is to use page objects, a data model where you can associate page element selectors and methods that perform actions on them in an object-oriented format. It makes it easy to share and reuse code across tests without rewriting the same things over and over, while also identifying how different pages look according to the “test code.”

What is contained in this package was a combination of paradigms on how I structured page objects within large test suites at previous organizations. It was mainly useful when a lot of repeated components appeared on the page. Because of how Cypress operates, it can be tedious to accurately filter for “nested” elements within duplicated sections. This package helps answer that by replicating the page object model against any possible structure of a particular page.

This particular model could inadvertently lead to some over-engineering, honestly, but helped interface between other layers of abstraction within a test (like Cucumber/Gherkin type tests). The package is a bit heavy for unit or component tests, but serves a purpose for strict structuring.