Skip to content

Commit b54dba5

Browse files
mturacSkn0tt
andauthored
fix: keep GitHub annotations parseable with dot reporter (microsoft#41292)
Signed-off-by: Simon Knott <info@simonknott.de> Co-authored-by: Simon Knott <info@simonknott.de>
1 parent 33458b7 commit b54dba5

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

packages/playwright/src/reporters/github.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ type GitHubLogOptions = Partial<{
3636
}>;
3737

3838
class GitHubLogger {
39+
newLine() {
40+
// eslint-disable-next-line no-restricted-properties
41+
process.stdout.write('\n');
42+
}
43+
3944
private _log(message: string, type: GitHubLogType = 'notice', options: GitHubLogOptions = {}) {
4045
message = message.replace(/\n/g, '%0A');
4146
const configs = Object.entries(options)
@@ -82,6 +87,7 @@ export class GitHubReporter extends TerminalReporter {
8287
if (!this._shouldPrintFailureAnnotations(test))
8388
return;
8489
this._failedTestCount++;
90+
this.githubLogger.newLine();
8591
for (const r of test.results)
8692
this._printFailureAnnotation(test, r, this._failedTestCount);
8793
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,18 @@ for (const useIntermediateMergeReport of [false, true] as const) {
115115
expect(summaryIndex).toBeGreaterThan(errorIndex);
116116
expect(result.exitCode).toBe(1);
117117
});
118+
119+
test('starts GitHub failure annotation on a new line with dot reporter', async ({ runInlineTest }) => {
120+
const result = await runInlineTest({
121+
'a.test.js': `
122+
const { test, expect } = require('@playwright/test');
123+
test('failing', async ({}) => {
124+
expect(1 + 1).toBe(3);
125+
});
126+
`
127+
}, { workers: 1, reporter: 'dot,github' }, { GITHUB_WORKSPACE: process.cwd() });
128+
expect(result.output).toContain('F\n::error file=');
129+
expect(result.exitCode).toBe(1);
130+
});
118131
});
119132
}

0 commit comments

Comments
 (0)