What's Your Favourite Cypress Command?

This was a really fun question from @rightsaidjames in the Slack Ask Me Anything with @marie.drake and Filip Hric

Whatโ€™s your favourite Cypress command?

Filip responded with

wow, Iโ€™m so enjoying this :joy: such a cool question :slightly_smiling_face:
I really love when I teach using Cypress and people literally freak out when they use network request stubbing, so it has to be combination of .server()
although Iโ€™m also really enjoying using .contains() command. it selects an element using text, which is neat and makes test super readable. also, you can specify this command by using .contains('button', 'Send') which is just going to select button elements that contain Send text.

one more thing comes to mind - some of my favourites are my own custom commands! :smile: recently I had a lot of fun rewriting my tests to typescript and creating custom types for them. this meant that I could customize my autocomplete in VS code and make commands that reflected my app logic :star_struck:

And Marie added

I like the invoke() command because of its versatility. You can invoke any attributes and either query it or update its value. I also like the cy.request() because with this command, I can test APIs too :slightly_smiling_face: cypress aliases too .as() because you can use this with fixtures, data selectors, requests, anything! itโ€™s very handy :slightly_smiling_face:

What about you? Whatโ€™s your favourite Cypress command?

I am all about that cy.request() life now. I used to run a POSTMAN script to set up my test users before the test run which worked(ish). Now I get Cypress to make the API calls to set up and tear down before each tests. Keeps things nice and tidy. :slight_smile:

1 Like