Cypress · Middle · Question 26 of 77
What is the difference between cy.spy and cy.stub?
- 1There is no difference; they are aliases
- 2A spy records calls and keeps the original; a stub replaces it
- 3A spy works only in Node; a stub only in the browser
Show the answer
Correct answer: A spy records calls and keeps the original; a stub replaces it
Explanation
Use a spy to check an analytics call happened, a stub to prevent a side effect or force a return value.