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: keep GitHub annotations parseable with dot reporter (#41292)
mehmet turacb54dba5945c0
diff --git a/packages/playwright/src/reporters/github.ts b/packages/playwright/src/reporters/github.tsindex d77b0cb3ee..6975adb1dd 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.tsindex 7bbb6a3386..6c57c1c34f 100644--- a/tests/playwright-test/reporter-github.spec.ts+++ b/tests/playwright-test/reporter-github.spec.ts@@ -115,5 +115,18 @@ 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() });+ expect(result.output).toContain('F\n::error file=');+ expect(result.exitCode).toBe(1);+ });});}