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

101
Views
Verify number of times window.close was called - cypress

I have created stub for window.close for cypress I want to know number of times it has been called .

 cy.window().then(win => {
   cy.stub(win, 'close').as('parentWindowCalled');
 });

I want to check whether window.close is never called . How can I do that ?

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

0

You would need the stub object

let stub
cy.window().then(win => {
  stub = cy.stub(win, 'close').as('parentWindowCalled');
})

// actions
cy.wait('@parentWindowCalled')
cy.wait('@parentWindowCalled')
cy.wait('@parentWindowCalled')

cy.then(() => expect(stub).to.have.been.called.exactly(3))

to.have.been.called is just extracting the call count from the spy, so you can chain other criteria like .have.been.called.at.least(3).

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!