feat(report): add video to attachments (#7976)

This commit is contained in:
Dmitry Gozman 2021-08-03 17:07:57 -07:00 committed by GitHub
parent 3e05d8e9fa
commit ea4f42b7ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -251,8 +251,9 @@ export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions,
return;
try {
const videoPath = await v.path();
const fileName = path.basename(videoPath);
await v.saveAs(testInfo.outputPath(fileName));
const savedPath = testInfo.outputPath(path.basename(videoPath));
await v.saveAs(savedPath);
testInfo.attachments.push({ name: 'video', path: savedPath, contentType: 'video/webm' });
} catch (e) {
// Silent catch empty videos.
}

View File

@ -301,8 +301,16 @@ test('should work with video: on-first-retry', async ({ runInlineTest }, testInf
const dirFail = testInfo.outputPath('test-results', 'a-fail-chromium');
expect(fs.existsSync(dirFail)).toBeFalsy();
const videoFailRetry = fs.readdirSync(testInfo.outputPath('test-results', 'a-fail-chromium-retry1')).find(file => file.endsWith('webm'));
const dirRetry = testInfo.outputPath('test-results', 'a-fail-chromium-retry1');
const videoFailRetry = fs.readdirSync(dirRetry).find(file => file.endsWith('webm'));
expect(videoFailRetry).toBeTruthy();
expect(result.report.suites[0].specs[1].tests[0].results[0].attachments).toEqual([]);
expect(result.report.suites[0].specs[1].tests[0].results[1].attachments).toEqual([{
name: 'video',
contentType: 'video/webm',
path: path.join(dirRetry, videoFailRetry),
}]);
});
test('should work with video size', async ({ runInlineTest }, testInfo) => {