mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(github reporter): handle global onError (#10256)
This commit is contained in:
parent
8fe3ea7972
commit
4c93417e8a
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
import milliseconds from 'ms';
|
import milliseconds from 'ms';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { BaseReporter, formatFailure, stripAnsiEscapes } from './base';
|
import { BaseReporter, formatError, formatFailure, stripAnsiEscapes } from './base';
|
||||||
import { TestCase, FullResult } from '../../types/testReporter';
|
import { TestCase, FullResult, TestError } from '../../types/testReporter';
|
||||||
|
|
||||||
type GitHubLogType = 'debug' | 'notice' | 'warning' | 'error';
|
type GitHubLogType = 'debug' | 'notice' | 'warning' | 'error';
|
||||||
|
|
||||||
@ -68,6 +68,11 @@ export class GitHubReporter extends BaseReporter {
|
|||||||
this._printAnnotations();
|
this._printAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override onError(error: TestError) {
|
||||||
|
const errorMessage = formatError(error, false).message;
|
||||||
|
this.githubLogger.error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
private _printAnnotations() {
|
private _printAnnotations() {
|
||||||
const summary = this.generateSummary();
|
const summary = this.generateSummary();
|
||||||
const summaryMessage = this.generateSummaryMessage(summary);
|
const summaryMessage = this.generateSummaryMessage(summary);
|
||||||
|
|||||||
@ -74,3 +74,21 @@ test('print GitHub annotations for slow tests', async ({ runInlineTest }) => {
|
|||||||
expect(text).toContain('::notice title=🎭 Playwright Run Summary:: 1 passed');
|
expect(text).toContain('::notice title=🎭 Playwright Run Summary:: 1 passed');
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('print GitHub annotations for global error', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'a.test.js': `
|
||||||
|
const test = pwt.test.extend({
|
||||||
|
w: [async ({}, use) => {
|
||||||
|
await use();
|
||||||
|
throw new Error('Oh my!');
|
||||||
|
}, { scope: 'worker' }],
|
||||||
|
});
|
||||||
|
test('passes but...', ({w}) => {
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { reporter: 'github' });
|
||||||
|
const text = stripAscii(result.output);
|
||||||
|
expect(text).toContain('::error ::%0AError: Oh my!%0A%0A');
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user