From 9baa1b0959b0021bfaad543b0ff9cf4a37177be0 Mon Sep 17 00:00:00 2001 From: mehmet turac Date: Sun, 14 Jun 2026 23:24:56 +0300 Subject: [PATCH] fix github reporter annotation newline --- packages/playwright/src/reporters/github.ts | 6 ++++++ tests/playwright-test/reporter-github.spec.ts | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/playwright/src/reporters/github.ts b/packages/playwright/src/reporters/github.ts index d77b0cb3ee1b6..6975adb1dd098 100644 --- a/packages/playwright/src/reporters/github.ts +++ b/packages/playwright/src/reporters/github.ts @@ -36,6 +36,11 @@ type GitHubLogOptions = Partial<{ }>; class GitHubLogger { + newLine() { + // eslint-disable-next-line no-restricted-properties + process.stdout.write('\n'); + } + private _log(message: string, type: GitHubLogType = 'notice', options: GitHubLogOptions = {}) { message = message.replace(/\n/g, '%0A'); const configs = Object.entries(options) @@ -82,6 +87,7 @@ export class GitHubReporter extends TerminalReporter { if (!this._shouldPrintFailureAnnotations(test)) return; this._failedTestCount++; + this.githubLogger.newLine(); for (const r of test.results) this._printFailureAnnotation(test, r, this._failedTestCount); } diff --git a/tests/playwright-test/reporter-github.spec.ts b/tests/playwright-test/reporter-github.spec.ts index 7bbb6a3386fb6..0084c85426786 100644 --- a/tests/playwright-test/reporter-github.spec.ts +++ b/tests/playwright-test/reporter-github.spec.ts @@ -115,5 +115,21 @@ for (const useIntermediateMergeReport of [false, true] as const) { expect(summaryIndex).toBeGreaterThan(errorIndex); expect(result.exitCode).toBe(1); }); + + test('starts GitHub failure annotation on a new line with dot reporter', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.test.js': ` + const { test, expect } = require('@playwright/test'); + test('failing', async ({}) => { + expect(1 + 1).toBe(3); + }); + ` + }, { workers: 1, reporter: 'dot,github' }, { GITHUB_WORKSPACE: process.cwd() }); + const text = result.output; + const annotationIndex = text.indexOf('::error file='); + expect(annotationIndex).toBeGreaterThan(0); + expect(text[annotationIndex - 1]).toBe('\n'); + expect(result.exitCode).toBe(1); + }); }); }