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

250
Views
Publicar datos de resultados en un sitio web (como una API o un bot de Telegram) después de una prueba en Cypress

He terminado de escribir mi primera prueba de Cypress. Todo está bien, excepto que tengo problemas para publicar los datos de los resultados en un sitio web. Porque quiero enviar los datos del resultado y también, si se produce algún error, la captura de pantalla del resultado a nuestro grupo de telegramas de compañeros de trabajo.

Durante los últimos dos días he intentado todo y no pude encontrar ninguna solución.

Los probé en mi script de prueba (cypress/integration/test.js);

 Cypress.on('test:after:run', (test, runnable) => { console.log('test,runnable', test, runnable) const details = { projectKey: Cypress.env('zephyr-project-key'), testName: test.invocationDetails.relativeFile, status: test.status, error: runnable.err.message, retries: runnable.retries.length, duration: test.wallClockDuration, startTime: test.wallClockStartedAt } cy.request('POST', 'http://mywebsite.com/notify.php', { body: details }) fetch('http://mywebsite.com/notify.php') })

Además, esto no funcionó (cypress/plugins/index.js);

 module.exports = (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('after:run', (results) => { if (results) { // results will be undefined in interactive mode console.log(results.totalPassed, 'out of', results.totalTests, 'passed') fetch('http://mywebsite.com/notify.php'); } }) }

Editar: este es el día 3 y todavía no pude resolver esto. Lo que he visto en la página de ayuda de Cypress es que las llamadas cy.task() no se activan en el bloque de eventos 'test:after:run';

https://github.com/cypress-io/cypress/issues/4823

He visto algunos grupos de Telegram que pueden hacer lo que estoy tratando de hacer. Todo lo que necesito es poder obtener los resultados y publicarlos en mi sitio web.

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

0

El tercer parámetro de cy.request() es body , no es necesario envolverlo.

 Cypress.on('test:after:run', (test, runnable) => { const details = { projectKey: Cypress.env('zephyr-project-key'), testName: test.invocationDetails.relativeFile, status: test.status, error: runnable.err?.message, // need err?.message if there is no error retries: runnable.retries.length, duration: test.wallClockDuration, startTime: test.wallClockStartedAt } cy.request('POST', 'http://mywebsite.com/notify.php', details) // don't wrap details .then(res => expect(res.status).to.eq(201)) // confirm result })
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!