Skip to content

Commit 48be646

Browse files
authored
cherry-pick(#36443): fix(blob): correctly type pre-1.53 onTestEnd event for attachments (#36476)
1 parent dc15556 commit 48be646

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

packages/playwright/src/reporters/merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class AttachmentPathPatcher {
451451
if (event.method === 'onAttach')
452452
this._patchAttachments((event.params as JsonTestResultOnAttach).attachments);
453453
else if (event.method === 'onTestEnd')
454-
this._patchAttachments((event.params as JsonTestResultEnd).attachments ?? []);
454+
this._patchAttachments((event.params.result as JsonTestResultEnd).attachments ?? []);
455455
}
456456

457457
private _patchAttachments(attachments: JsonAttachment[]) {

tests/assets/blob-1.52.zip

60.5 KB
Binary file not shown.

tests/playwright-test/reporter-blob.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,39 @@ test('merge-reports should throw if report version is from the future', async ({
15051505

15061506
});
15071507

1508+
test('merge-reports should merge old attachments (pre-1.53)', async ({ runInlineTest, mergeReports }) => {
1509+
const reportDir = test.info().outputPath('blob-report');
1510+
1511+
const files = {
1512+
'playwright.config.ts': `
1513+
module.exports = {
1514+
reporter: [['blob']]
1515+
};
1516+
`,
1517+
'tests/a.test.js': `
1518+
import { test, expect } from '@playwright/test';
1519+
test('test 1', async ({}) => {});
1520+
`,
1521+
'merge.config.ts': `module.exports = {
1522+
testDir: 'mergeRoot',
1523+
};`,
1524+
};
1525+
1526+
await runInlineTest(files);
1527+
const reportFiles = await fs.promises.readdir(reportDir);
1528+
expect(reportFiles).toEqual(['report.zip']);
1529+
1530+
await fs.promises.copyFile(path.join(__dirname, '../assets/blob-1.52.zip'), path.join(reportDir, 'blob-1.42.zip'));
1531+
1532+
const { exitCode } = await mergeReports(reportDir, { 'PLAYWRIGHT_HTML_OPEN': 'never' }, { additionalArgs: ['--reporter', 'html', '--config', 'merge.config.ts'] });
1533+
expect(exitCode).toBe(0);
1534+
1535+
const assets = await fs.promises.readdir(path.join(test.info().outputPath('playwright-report'), 'data'));
1536+
expect(new Set(assets)).toEqual(new Set([
1537+
'4b6deb4234e5c2dc92efc6e604624e9481e8ae57.png', // screenshot
1538+
]));
1539+
});
1540+
15081541
test('should merge blob reports with same name', async ({ runInlineTest, mergeReports, showReport, page }) => {
15091542
const files = {
15101543
'playwright.config.ts': `

0 commit comments

Comments
 (0)