Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/playwright/src/reporters/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down
16 changes: 16 additions & 0 deletions tests/playwright-test/reporter-github.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}