Skip to content
masterclass Buddy

Cypress · Function

cy.spy

cy.spy() wraps a function or object method to record calls and arguments. It leaves the original behavior unchanged, so the real function still runs.

Last updated

Since
0.18.8

Syntax

cy.spy(object, method)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • .as()
  • cy.clock()
  • cy.stub()
  • Stubs, Spies, and Clocks
  • Recipe: Stubbing, Spying

Source: cy.spy() | Cypress API Documentation. Checked 2026-11-03.