Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: step id not found error log (#37748)
Simon Knotteb42923b1632
diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.tsindex e4add9bbae..c007255bcc 100644--- a/packages/playwright/src/worker/testInfo.ts+++ b/packages/playwright/src/worker/testInfo.ts@@ -459,15 +459,20 @@ export class TestInfoImpl implements TestInfo {});this._attach(await normalizeAndSaveAttachment(this.outputPath(), name, options),- step.group ? undefined : step.stepId+ step.stepId);step.complete({});}_attach(attachment: TestInfo['attachments'][0], stepId: string | undefined) {const index = this._attachmentsPush(attachment) - 1;- if (stepId) {- this._stepMap.get(stepId)!.attachmentIndices.push(index);++ let step = stepId ? this._stepMap.get(stepId) : undefined;+ if (!!step?.group)+ step = undefined;++ if (step) {+ step.attachmentIndices.push(index);} else {const stepId = `attach@${createGuid()}`;this._tracing.appendBeforeActionForStep({ stepId, title: `Attach ${escapeWithQuotes(attachment.name, '"')}`, category: 'test.attach', stack: [] });@@ -480,7 +485,7 @@ export class TestInfoImpl implements TestInfo {contentType: attachment.contentType,path: attachment.path,body: attachment.body?.toString('base64'),- stepId,+ stepId: step?.stepId,});}diff --git a/tests/playwright-test/reporter-attachment.spec.ts b/tests/playwright-test/reporter-attachment.spec.tsindex 65a536e77f..8935acd73c 100644--- a/tests/playwright-test/reporter-attachment.spec.ts+++ b/tests/playwright-test/reporter-attachment.spec.ts@@ -323,7 +323,7 @@ test('render text attachment with multiple lines', async ({ runInlineTest }) =>expect(result.exitCode).toBe(1);});-test('attaching inside boxed fixture should not log error', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/37147' } }, async ({ runInlineTest }) => {+test('attaching inside boxed fixture should not log error', { annotation: [{ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/37147' }, { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/37747' }] }, async ({ runInlineTest }) => {const result = await runInlineTest({'a.test.ts': `import { test as base } from '@playwright/test';@@ -334,6 +334,11 @@ test('attaching inside boxed fixture should not log error', { annotation: { typebody: 'foo',contentType: 'text/plain',});+ testInfo.attachments.push({+ name: 'my attachment 2',+ body: Buffer.from('bar'),+ contentType: 'text/plain',+ });await use();}, { box: true }],});@@ -343,9 +348,6 @@ test('attaching inside boxed fixture should not log error', { annotation: { type});`,}, { reporter: 'line' }, {});- const text = result.output;- expect(text).toContain(' attachment #1: my attachment (text/plain) ──────────────────────────────────────────────────────');- expect(text).toContain(' foo');- expect(text).toContain(' ────────────────────────────────────────────────────────────────────────────────────────────────');+ expect(result.output).not.toContain('step id not found');expect(result.exitCode).toBe(1);});