Company
Date Published
Author
Gleb Bahmutov
Word count
6958
Language
English
Hacker News points
None

Summary

Gleb Bahmutov's article argues against the use of page objects in end-to-end testing, particularly within the Cypress.io ecosystem, and advocates for the use of application actions instead. Page objects, while traditionally used to create a layer of abstraction for test maintenance, are critiqued for being difficult to maintain, introducing additional state, and slowing down tests by forcing interactions through the user interface. Bahmutov suggests directly dispatching actions to the application's internal logic, which can improve test speed and maintainability by leveraging Cypress's ability to run test code alongside application code. This approach not only speeds up tests—sometimes by as much as 50%—but also influences better application code refactoring, as tests become directly tied to the application's internal model interface rather than an unstable UI. Additionally, using application actions can lead to more focused error reporting and allows tests to be faster and more robust by bypassing the UI in favor of direct model manipulation.