Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Is there a way to trigger a hook after the execution of a specific command in cypress

I am trying to monitor the state of the DOM after each call to cy.get and cy.find. I noticed that there are hooks in cypress but they only allow me to run before or after the test. I also looked at plugins, but I am not sure they would allow me to achieve what I am trying to do (I might be missing something though since I am a newbie in cypress).

So basically, my question is: Is it possible to trigger some kind of hook, that would be called every time a specific command is called by the cypress process?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

"Command" is a generic term for Cypress language feature that start with cy..

Some, like cy.get() and .find() are querying commands and have no affect on the DOM.

Others like .click() trigger an event in the app that may change the DOM, so you would use querying commands to see what has changed, or more precisely to test that what you expect to change have indeed changed.

Hooks you mention like beforeEach() and afterEach() are mocha hooks that intercept stages of the test, but they do not query the DOM.

There are also other events that will run some code after Cypress does something, but that's advanced stuff, not often used, and too broad to answer without a specific use-case.


If you want to look at inner workings of the Cypress queue, review this blog Visualize Cypress Command Queue and the accompanying video.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!