Last active
December 19, 2020 15:02
-
-
Save samlucax/3dca4b95498cf618c8dedaae2945bd95 to your computer and use it in GitHub Desktop.
Adicionar imagens + vídeos no relatório do Mochawesome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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