diff --git a/packages/playwright/src/runner/dispatcher.ts b/packages/playwright/src/runner/dispatcher.ts index 0dc46287c4..534fe7eb4a 100644 --- a/packages/playwright/src/runner/dispatcher.ts +++ b/packages/playwright/src/runner/dispatcher.ts @@ -362,8 +362,13 @@ class JobDispatcher { body: params.body !== undefined ? Buffer.from(params.body, 'base64') : undefined }; data.result.attachments.push(attachment); - if (params.stepId) - data.steps.get(params.stepId)!.attachments.push(attachment); + if (params.stepId) { + const step = data.steps.get(params.stepId); + if (step) + step.attachments.push(attachment); + else + this._reporter.onStdErr?.('Internal error: step id not found: ' + params.stepId); + } } private _failTestWithErrors(test: TestCase, errors: TestError[]) {