allure-framework / allure-js

Allure integrations for JavaScript test frameworks
https://allurereport.org/
Apache License 2.0
225 stars 121 forks source link

How to add video as an attachment to allure cucumber-js report in BDD cucumber framework #652

Closed samplehub closed 2 months ago

samplehub commented 1 year ago

Describe the bug How to add video as an attachement to allure cucumber-js report.

To Reproduce Steps to reproduce the behavior: Create BDD cucumber Playwright framework Add allure-reporter . Ref : https://github.com/allure-framework/allure-js/blob/master/packages/allure-cucumberjs/README.md Create Hooks.ts file where the tests are invoked from a context with record video parameter

Before Hooks this.context = await global.browser.newContext({ storageState: path.join(workingDir, test/testData/storageStates/xyz.json), recordVideo: { dir: ${global.videosPath}/${global.testName} }

After Hooks this.attach(${global.videosPath}/${global.testName}, 'video/webm');

Expected behaviour Shall be able to add and play videos as an attachment in BDD framework .

Screenshots Empty video files are attached to the report image I am able to attach screenshots & json files fine
image

Desktop (please complete the following information):

Additional context Please can you provide quick example how to attach videos in the above scenarios. Thanks in advance

samplehub commented 1 year ago

Issue has been resolved. Solution : const videoPath = await this.page?.video().path(); this.attach(fs.readFileSync(videoPath), 'video/webm');