chore: update "X fatal errors" message (#16325)
Also, exlude certain errors from triggering this message: - `no tests found` - `duplicate test titles are not allowed` - `--forbid-only found a focused test` - `Timed out waiting 3600s for the entire test run`
This commit is contained in:
Родитель
8ed238843b
Коммит
f6d94f0ac9
|
@ -98,6 +98,7 @@ export class BaseReporter implements ReporterInternal {
|
|||
}
|
||||
|
||||
onError(error: TestError) {
|
||||
if (!(error as any).__isNotAFatalError)
|
||||
this._fatalErrors.push(error);
|
||||
}
|
||||
|
||||
|
@ -136,8 +137,6 @@ export class BaseReporter implements ReporterInternal {
|
|||
|
||||
protected generateSummaryMessage({ skipped, expected, interrupted, unexpected, flaky, fatalErrors }: TestSummary) {
|
||||
const tokens: string[] = [];
|
||||
if (fatalErrors.length)
|
||||
tokens.push(colors.red(` ${fatalErrors.length} fatal ${fatalErrors.length === 1 ? 'error' : 'errors'}`));
|
||||
if (unexpected.length) {
|
||||
tokens.push(colors.red(` ${unexpected.length} failed`));
|
||||
for (const test of unexpected)
|
||||
|
@ -159,6 +158,8 @@ export class BaseReporter implements ReporterInternal {
|
|||
tokens.push(colors.green(` ${expected} passed`) + colors.dim(` (${milliseconds(this.duration)})`));
|
||||
if (this.result.status === 'timedout')
|
||||
tokens.push(colors.red(` Timed out waiting ${this.config.globalTimeout / 1000}s for the entire test run`));
|
||||
if (fatalErrors.length)
|
||||
tokens.push(colors.red(` ${fatalErrors.length === 1 ? '1 error was not a part of any test' : fatalErrors.length + ' errors were not a part of any test'}, see above for details`));
|
||||
|
||||
return tokens.join('\n');
|
||||
}
|
||||
|
|
|
@ -971,7 +971,7 @@ function createNoTestsError(): TestError {
|
|||
}
|
||||
|
||||
function createStacklessError(message: string): TestError {
|
||||
return { message };
|
||||
return { message, __isNotAFatalError: true } as any;
|
||||
}
|
||||
|
||||
export const builtInReporters = ['list', 'line', 'dot', 'json', 'junit', 'null', 'github', 'html'] as const;
|
||||
|
|
|
@ -316,5 +316,5 @@ test('should report fatal errors at the end', async ({ runInlineTest }) => {
|
|||
}, { reporter: 'list' });
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.passed).toBe(2);
|
||||
expect(stripAnsi(result.output)).toContain('2 fatal errors');
|
||||
expect(stripAnsi(result.output)).toContain('2 errors were not a part of any test, see above for details');
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче