Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(blob): correctly type pre-1.53 onTestEnd event for attachments (#36443)

Adam Gastineau735c53678587
diff --git a/packages/playwright/src/reporters/merge.ts b/packages/playwright/src/reporters/merge.ts
index 5fe408b929..03fd23b12a 100644
--- a/packages/playwright/src/reporters/merge.ts
+++ b/packages/playwright/src/reporters/merge.ts
@@ -451,7 +451,7 @@ class AttachmentPathPatcher {
if (event.method === 'onAttach')
this._patchAttachments((event.params as JsonTestResultOnAttach).attachments);
else if (event.method === 'onTestEnd')
- this._patchAttachments((event.params as JsonTestResultEnd).attachments ?? []);
+ this._patchAttachments((event.params.result as JsonTestResultEnd).attachments ?? []);
}
private _patchAttachments(attachments: JsonAttachment[]) {
diff --git a/tests/assets/blob-1.52.zip b/tests/assets/blob-1.52.zip
new file mode 100644
index 0000000000..5b1d5cf4a5
Binary files /dev/null and b/tests/assets/blob-1.52.zip differ
diff --git a/tests/playwright-test/reporter-blob.spec.ts b/tests/playwright-test/reporter-blob.spec.ts
index 2b7be0dbab..26cd4082db 100644
--- a/tests/playwright-test/reporter-blob.spec.ts
+++ b/tests/playwright-test/reporter-blob.spec.ts
@@ -1505,6 +1505,39 @@ test('merge-reports should throw if report version is from the future', async ({
});
+test('merge-reports should merge old attachments (pre-1.53)', async ({ runInlineTest, mergeReports }) => {
+ const reportDir = test.info().outputPath('blob-report');
+
+ const files = {
+ 'playwright.config.ts': `
+ module.exports = {
+ reporter: [['blob']]
+ };
+ `,
+ 'tests/a.test.js': `
+ import { test, expect } from '@playwright/test';
+ test('test 1', async ({}) => {});
+ `,
+ 'merge.config.ts': `module.exports = {
+ testDir: 'mergeRoot',
+ };`,
+ };
+
+ await runInlineTest(files);
+ const reportFiles = await fs.promises.readdir(reportDir);
+ expect(reportFiles).toEqual(['report.zip']);
+
+ await fs.promises.copyFile(path.join(__dirname, '../assets/blob-1.52.zip'), path.join(reportDir, 'blob-1.42.zip'));
+
+ const { exitCode } = await mergeReports(reportDir, { 'PLAYWRIGHT_HTML_OPEN': 'never' }, { additionalArgs: ['--reporter', 'html', '--config', 'merge.config.ts'] });
+ expect(exitCode).toBe(0);
+
+ const assets = await fs.promises.readdir(path.join(test.info().outputPath('playwright-report'), 'data'));
+ expect(new Set(assets)).toEqual(new Set([
+ '4b6deb4234e5c2dc92efc6e604624e9481e8ae57.png', // screenshot
+ ]));
+});
+
test('should merge blob reports with same name', async ({ runInlineTest, mergeReports, showReport, page }) => {
const files = {
'playwright.config.ts': `