https://cypress.io logo
As for "page objects" I don't disagree with the ne...
# best-practices
l
As for "page objects" I don't disagree with the need to centralize repeated stuff and reduce clutter, but... 1. Not every website can be easily lumped into "pages". The metaphor is often too forced, resulting in confusion and extra work trying to make it happen. 2. Especially for Cypress, I don't see the value of using an object. For one, custom commands exist on the
cy
object by default, and I'm not a fan of trying to complicate that any further. Start by creating custom commands for common actions, then see what is left over. My guess is that this alone will reduce most of the element selector redundancy that "page object model" is supposed to alleviate. I also find CTRL-SHIFT-H (replace in files) is perfectly fine in most cases. Do what makes sense for your group but don't overengineer just to fit someone else's model. You'll find it even more difficult to manage your stuff than when you began. Some of my own principles: 1. Make tests easy to read 2. Make tests easy to write 3. Make tests easy to update If you send me on a wild goose chase looking for where some obscure element is warehoused in the code, that violates all three.