webdriverio-community / wdio-video-reporter

Reporter for WebdriverIO that makes videos of failed tests and has optional allure integration
https://webdriver.io/docs/wdio-video-reporter
MIT License
57 stars 47 forks source link

Videos generated are not attached to an allure report if using Mocha before / beforeEach hooks #272

Open GibDot opened 3 months ago

GibDot commented 3 months ago

Describe the bug Videos generated are not attached correctly to the allure report if a before / beforeEach hook exists in Mocha.

Log:

[2024-04-15T19:00:35.834Z] Adding execution video attachment as /Users/.../.../wdio_video_temp/allure-results/Should-fail-0-0--CHROME--2024-04-15--15-00-35-817.webm
[2024-04-15T19:00:37.763Z] Add frame for command: /session/:sessionId/url => [url]
[2024-04-15T19:00:41.091Z] Add frame for command: /session/:sessionId/url => [url]
[2024-04-15T19:00:41.195Z] - Screenshot (frame: 0)
[2024-04-15T19:00:41.300Z] - Screenshot (frame: 1)
[2024-04-15T19:00:41.311Z] Add frame for command: /session/:sessionId/execute/sync => [sync]
[2024-04-15T19:00:41.471Z] - Screenshot (frame: 2)
[2024-04-15T19:00:41.472Z] Add frame for command: /session/:sessionId/execute/sync => [sync]
[2024-04-15T19:00:41.564Z] - Screenshot (frame: 3)
[2024-04-15T19:00:43.590Z] ffmpeg command: "/Users/.../.../wdio_video_temp/node_modules/@ffmpeg-installer/darwin-arm64/ffmpeg" -y -r 10 -i "/Users/.../.../wdio_video_temp/allure-results/.video-reporter-screenshots/Should-fail-0-0--CHROME--2024-04-15--15-00-35-817/%04d.png" -vcodec libvpx-vp9 -crf 32 -pix_fmt yuv420p -vf "scale=1200:trunc(ow/a/2)*2","setpts=3.0*PTS" "/Users/.../.../wdio_video_temp/allure-results/Should-fail-0-0--CHROME--2024-04-15--15-00-35-817.webm"
[2024-04-15T19:00:43.690Z] Screenshot not available (frame: 4). Error: Error: There isn't any active test!..
[2024-04-15T19:00:44.041Z] Screenshot not available (frame: 5). Error: RequestError: connect ECONNREFUSED 0.0.0.0:62345..
[2024-04-15T19:00:44.197Z] Generated video: "/Users/.../.../wdio_video_temp/allure-results/Should-fail-0-0--CHROME--2024-04-15--15-00-35-817.webm" (607ms)
[2024-04-15T19:00:44.197Z] Generated 1 videos, video report done!

To Reproduce

Test File:

describe('WDIO Video Test', () => {
    beforeEach(async () => {
        await browser.navigateTo('https://www.google.com/')
    })

    it('Should fail', async () => {
        await browser.navigateTo('https://webdriver.io/')
        await $('.footer__title').scrollIntoView()
        await browser.pause(2000)
        await expect(1).toEqual(2)
    })
})

package.json:

{
  "name": "wdio_video_temp",
  "type": "module",
  "devDependencies": {
    "@babel/core": "^7.24.4",
    "@babel/preset-env": "^7.24.4",
    "@babel/register": "^7.23.7",
    "@wdio/allure-reporter": "^8.14.0",
    "@wdio/cli": "^8.36.0",
    "@wdio/local-runner": "^8.36.0",
    "@wdio/mocha-framework": "^8.36.0",
    "@wdio/spec-reporter": "^8.36.0",
    "wdio-video-reporter": "^5.2.0"
  },
  "scripts": {
    "wdio": "wdio run ./wdio.conf.js"
  }
}

wdio.conf.js:

Boiler plate configuration with the below updates to reporters:

    reporters: ['spec',
        ['allure',
            { outputDir: 'allure-results' }],
        ['video',
            {
                outputDir: 'allure-results',
                saveAllVideos: false,
            }]
    ],

Expected behavior:

I expect the video files that are generated and present within the output directory to be included in the Allure Report when using before / beforeEach hooks.

Environment (please complete the following information):

Desktop (please complete the following information):

Additional context:

christian-bromann commented 3 months ago

Thanks for reporting @GibDot , any help to get this issue resolved would be much appreciated.