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

115
Views
Cypress - propiedad de ventana simulada

Tengo un código que usa window.foo.abc como condición para mostrar algo.

Quiero probar esta funcionalidad con ciprés y quiero burlarme de este valor para que sea falso y verdadero.

¿Cómo puedo hacer eso?

He intentado

 before(function() { Cypress.on('window:before:load', win => { win.foo.abc = true; });

y

 cy.window().then(win => { window.foo.abc = true; });

sin exito

¿Cómo puedo burlarme de este valor?

gracias 🙏

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

0

Este código es incorrecto,

 Cypress.on('window:before:load', win => { window.foo.abc = true; });

Debería ser

 Cypress.on('window:before:load', win => { win.foo.abc = true; });

No tiene que usarlo before() , pero debería estar en la parte superior de la especificación.

Pero sospecho que aún no funcionará después de la corrección, lo más probable es que la aplicación restablezca foo a un nuevo objeto durante la carga, es decir, durante cy.visit()

Puedes usar el segundo bloque

 cy.visit('...') // visit before changing cy.window().then(win => { win.foo.abc = true; // correct the syntax here as well })
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!