Skip to content

Instantly share code, notes, and snippets.

@samlucax
Last active December 19, 2020 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samlucax/3dca4b95498cf618c8dedaae2945bd95 to your computer and use it in GitHub Desktop.
Save samlucax/3dca4b95498cf618c8dedaae2945bd95 to your computer and use it in GitHub Desktop.
Adicionar imagens + vídeos no relatório do Mochawesome
// Adicionar este código dentro de support/index.js
// Importante: aplicável para projetos que usam o mochawesome como relatório
// No cypress.json, setar as seguintes configs:
// "screenshotsFolder": "mochawesome-report/assets",
// "videosFolder": "mochawesome-report/videos"
import './commands'
import addContext from 'mochawesome/addContext'
Cypress.on("test:after:run", (test, runnable) => {
// se o teste falhar, adiciona a imagem da falha ao relatório
if(test.state === 'failed') {
const screenshotFileName = `${runnable.parent.title} -- ${test.title} (failed).png`;
addContext({ test }, `assets/${Cypress.spec.name}/${screenshotFileName}`);
}
// adiciona o vídeo gerado durante a execução ao relatório
let videoName = Cypress.spec.name
videoName = `${videoName.replace('/.js.*', 'js')}.mp4`
addContext({ test }, `videos/${videoName}`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment