bahmutov / bahmutov/cy-report-example
`cypress-mochawesome-reporter` Videos without retry
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Hey @bahmutov ,
Thanks for the article!
I had a look into why you needed `retries: 1` to get videos working - it's because the [code which adds context to the report](https://github.com/LironEr/cypress-mochawesome-reporter/blob/b955889804a8215a298dfc127bde7385e64a605d/register.js#L12) and your [code which adds videos](https://github.com/bahmutov/cy-report-example/blob/cypress-mochawesome-reporter/cypress/support/e2e.js#L3) both rely on the the `test:after:run` event. I couldn't find any detail in Cypress, but I guessed it would run event handlers in the order they're added - currently, the `import 'cypress-mochawesome-reporter/register'` adds the handler to put context items into the report, then your code adds the handler to put the video in the context.
If you switch those round (so videos are put into context before context is put into the report), videos work without retries :tada:
```
Cypress.on('test:after:run', (test, runnable) => {
if (Cypress.config('video')) {
// assuming the videos are stored in "cypress/videos"
const videoFile = `../videos/${Cypress.spec.name}.mp4`
if (Cypress.Mochawesome) {
Cypress.Mochawesome.context.push(videoFile)
}
}
})
// Must come after the event handler which adds video to the context
import 'cypress-mochawesome-reporter/register'
```
Cheers,
Nick
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading cypress/support/e2e.js and the referenced register.js handler, then reproduce the report with video enabled and no retry. Verify the event-handler ordering and determine whether the example should be updated so videos appear without retries; done means the generated Mochawesome report includes the video without configuring retries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cypress, javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100