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

190
Views
¿Hay una mejor manera de afirmar que todas las solicitudes interceptadas tienen éxito en Cypress?

Estoy tratando de probar que las 12 solicitudes involucradas en la creación de un objeto son exitosas, hasta ahora esta es la única forma en que puedo averiguar que funciona. ¿HAY una forma mejor/más eficiente/más flexible que no se rompa tan pronto como agreguemos o eliminemos una solicitud?

 cy.intercept('/api/**/**').as('objectCreation'); $button.click(); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200); cy.wait('@objectCreation').its('response.statusCode').should('eq', 200);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Me gustaría más detalles sobre su pregunta:

  • ¿Las solicitudes son idénticas?

Sin embargo, para responder a su pregunta sobre cómo simplificar su fragmento de código compartido... puede crear una variable represente los intentos de creación de la request y seguir llamando al método cy.intercept() y afirmando su response hasta que alcance la cantidad de creación de solicitud especificada. al igual que:

 const reqObjCreationNum = 0; // reqObjCreationNum object creation attempts number /** * @param {number} reqObjCreationNum - number of object creation attempts */ const createObject = ({ reqObjCreationNum }) => { cy.intercept('/api/**/**').as('objectCreation'); while (reqObjCreationNum <= 12) { cy.wait('@objectCreation') .its('response.statusCode') .should('eq', 200); reqObjCreationNum += 1; } }; createObject({ reqObjCreationNum });

Sugeriría el concepto de programación DRY como una lectura futura.

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!