Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trigger vs Should in Cypress

Can someone please explain me what is the difference between cy.get(selector).trigger(‘be.visible’) and cy.get(selector).should(‘be.visible’)

I’ve seen that they are working in similar way I and I wanted to know deeper because in official documentation I saw only should(‘be.visible’) is explained.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

.trigger() can only be used with events, but .trigger('be.visible') is not sending an event.

It’s attempting to make a chaijs assertion in the wrong command, and will throw an error if you use it.

Syntax
.trigger(eventName)
.trigger(eventName, position)
.trigger(eventName, options)
.trigger(eventName, x, y)
.trigger(eventName, position, options)
.trigger(eventName, x, y, options)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading