https://cypress.io logo
Implementing Cypress App Actions
# i-need-help
g
Hello, I am relatively new to using Cypress and I am currently trying to determine if POM or Cypress app actions would be best to implement. I've read a few articles explaining the differences between the two and the pros/cons of each. The consensus seems to favor app actions, however, this is a new concept for me, and I'm wondering if Cypress app actions can be used on legacy code. From what I learned, the app would need to be exposed using
if (window.Cypress) {window.model = model }
in the application code and then using
cy.window().its(‘model’)
to call the internal logic within my spec file. Is exposing the application something that a developer can easily add to existing files without much effort or would it be best for me to implement POM in this scenario?
a
If you're new to Cypress, you probably don't need to be asking this question yet. Just create some custom commands that you can think of as "macros" to perform repeated steps like "Log in", "Navigate to page", etc.
App Actions are a fairly big-brain way to do things. They're powerful, but they move you further away from "testing like a user". I prefer to do as much work as possible via the UI, to test the system in as realistic a way as I can. Not to say you can't move toward them over time... but I wouldn't start with that level of abstract architecture in your testing journey.
g
Very insightful! I am familiar with POM because that is what I used at the previous company I worked at (except they used robotframework for their automation testing). Due to the fact that the current place I work at is wanting to optimize its automation code, I was trying to find the best way to do that. However, you make a valid point about app actions moving QA further away from testing like a user. Thank you for your input!
a
Are you a new team member or principal on a legacy Cypress codebase, replacing a legacy test set with Cypress, or starting from no legacy tests with Cypress?
g
There are existing tests but the company wants to scrap them since they are doing a "facelift" on their web app, so I am basically starting from scratch.
a
Yeah I would focus more on establishing a set of tests that run as often as possible and then coming back to the architectural questions once you have enough complexity that you need to manage it.