fix(reporters): move Running X tests using Y workers to reporters (#10014)
This commit is contained in:
parent
c373986ca0
commit
3120f81629
|
|
@ -58,6 +58,7 @@ export class BaseReporter implements Reporter {
|
|||
duration = 0;
|
||||
config!: FullConfig;
|
||||
suite!: Suite;
|
||||
totalTestCount = 0;
|
||||
result!: FullResult;
|
||||
fileDurations = new Map<string, number>();
|
||||
monotonicStartTime: number = 0;
|
||||
|
|
@ -72,6 +73,7 @@ export class BaseReporter implements Reporter {
|
|||
this.monotonicStartTime = monotonicTime();
|
||||
this.config = config;
|
||||
this.suite = suite;
|
||||
this.totalTestCount = suite.allTests().length;
|
||||
}
|
||||
|
||||
onStdOut(chunk: string | Buffer, test?: TestCase, result?: TestResult) {
|
||||
|
|
@ -106,6 +108,12 @@ export class BaseReporter implements Reporter {
|
|||
this.result = result;
|
||||
}
|
||||
|
||||
protected generateStartingMessage() {
|
||||
const jobs = Math.min(this.config.workers, (this.config as any).__testGroupsCount);
|
||||
const shardDetails = this.config.shard ? `, shard ${this.config.shard.current} of ${this.config.shard.total}` : '';
|
||||
return `\nRunning ${this.totalTestCount} test${this.totalTestCount > 1 ? 's' : ''} using ${jobs} worker${jobs > 1 ? 's' : ''}${shardDetails}`;
|
||||
}
|
||||
|
||||
protected getSlowTests(): [string, number][] {
|
||||
if (!this.config.reportSlowTests)
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import colors from 'colors/safe';
|
||||
import { BaseReporter } from './base';
|
||||
import { FullResult, TestCase, TestResult } from '../../types/testReporter';
|
||||
import { FullResult, TestCase, TestResult, FullConfig, Suite } from '../../types/testReporter';
|
||||
|
||||
class DotReporter extends BaseReporter {
|
||||
private _counter = 0;
|
||||
|
|
@ -25,6 +25,11 @@ class DotReporter extends BaseReporter {
|
|||
return true;
|
||||
}
|
||||
|
||||
override onBegin(config: FullConfig, suite: Suite) {
|
||||
super.onBegin(config, suite);
|
||||
console.log(this.generateStartingMessage());
|
||||
}
|
||||
|
||||
override onStdOut(chunk: string | Buffer, test?: TestCase, result?: TestResult) {
|
||||
super.onStdOut(chunk, test, result);
|
||||
if (!this.config.quiet)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import { BaseReporter, formatFailure, formatTestTitle } from './base';
|
|||
import { FullConfig, TestCase, Suite, TestResult, FullResult } from '../../types/testReporter';
|
||||
|
||||
class LineReporter extends BaseReporter {
|
||||
private _total = 0;
|
||||
private _current = 0;
|
||||
private _failures = 0;
|
||||
private _lastTest: TestCase | undefined;
|
||||
|
|
@ -30,7 +29,7 @@ class LineReporter extends BaseReporter {
|
|||
|
||||
override onBegin(config: FullConfig, suite: Suite) {
|
||||
super.onBegin(config, suite);
|
||||
this._total = suite.allTests().length;
|
||||
console.log(this.generateStartingMessage());
|
||||
console.log();
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +60,7 @@ class LineReporter extends BaseReporter {
|
|||
override onTestEnd(test: TestCase, result: TestResult) {
|
||||
super.onTestEnd(test, result);
|
||||
const width = process.stdout.columns! - 1;
|
||||
const title = `[${++this._current}/${this._total}] ${formatTestTitle(this.config, test)}`.substring(0, width);
|
||||
const title = `[${++this._current}/${this.totalTestCount}] ${formatTestTitle(this.config, test)}`.substring(0, width);
|
||||
process.stdout.write(`\u001B[1A\u001B[2K${title}\n`);
|
||||
|
||||
if (!this.willRetry(test) && (test.outcome() === 'flaky' || test.outcome() === 'unexpected')) {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class ListReporter extends BaseReporter {
|
|||
|
||||
override onBegin(config: FullConfig, suite: Suite) {
|
||||
super.onBegin(config, suite);
|
||||
console.log(this.generateStartingMessage());
|
||||
console.log();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,13 +296,7 @@ export class Runner {
|
|||
filterSuite(rootSuite, () => false, test => shardTests.has(test));
|
||||
total = rootSuite.allTests().length;
|
||||
}
|
||||
|
||||
if (process.stdout.isTTY) {
|
||||
console.log();
|
||||
const jobs = Math.min(config.workers, testGroups.length);
|
||||
const shardDetails = shard ? `, shard ${shard.current} of ${shard.total}` : '';
|
||||
console.log(`Running ${total} test${total > 1 ? 's' : ''} using ${jobs} worker${jobs > 1 ? 's' : ''}${shardDetails}`);
|
||||
}
|
||||
(config as any).__testGroupsCount = testGroups.length;
|
||||
|
||||
let sigint = false;
|
||||
let sigintCallback: () => void;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ test('should retry timeout', async ({ runInlineTest }) => {
|
|||
expect(exitCode).toBe(1);
|
||||
expect(passed).toBe(0);
|
||||
expect(failed).toBe(1);
|
||||
expect(stripAscii(output).split('\n')[0]).toBe('××T');
|
||||
expect(stripAscii(output).split('\n')[2]).toBe('××T');
|
||||
});
|
||||
|
||||
test('should fail on unexpected pass with retries', async ({ runInlineTest }) => {
|
||||
|
|
@ -103,7 +103,7 @@ test('should retry unexpected pass', async ({ runInlineTest }) => {
|
|||
expect(exitCode).toBe(1);
|
||||
expect(passed).toBe(0);
|
||||
expect(failed).toBe(1);
|
||||
expect(stripAscii(output).split('\n')[0]).toBe('××F');
|
||||
expect(stripAscii(output).split('\n')[2]).toBe('××F');
|
||||
});
|
||||
|
||||
test('should not retry expected failure', async ({ runInlineTest }) => {
|
||||
|
|
@ -123,7 +123,7 @@ test('should not retry expected failure', async ({ runInlineTest }) => {
|
|||
expect(exitCode).toBe(0);
|
||||
expect(passed).toBe(2);
|
||||
expect(failed).toBe(0);
|
||||
expect(stripAscii(output).split('\n')[0]).toBe('··');
|
||||
expect(stripAscii(output).split('\n')[2]).toBe('··');
|
||||
});
|
||||
|
||||
test('should retry unhandled rejection', async ({ runInlineTest }) => {
|
||||
|
|
@ -141,7 +141,7 @@ test('should retry unhandled rejection', async ({ runInlineTest }) => {
|
|||
expect(result.exitCode).toBe(1);
|
||||
expect(result.passed).toBe(0);
|
||||
expect(result.failed).toBe(1);
|
||||
expect(stripAscii(result.output).split('\n')[0]).toBe('××F');
|
||||
expect(stripAscii(result.output).split('\n')[2]).toBe('××F');
|
||||
expect(result.output).toContain('Unhandled rejection');
|
||||
});
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ test('should retry beforeAll failure', async ({ runInlineTest }) => {
|
|||
expect(result.passed).toBe(0);
|
||||
expect(result.failed).toBe(1);
|
||||
expect(result.skipped).toBe(1);
|
||||
expect(stripAscii(result.output).split('\n')[0]).toBe('×°×°F°');
|
||||
expect(stripAscii(result.output).split('\n')[2]).toBe('×°×°F°');
|
||||
expect(result.output).toContain('BeforeAll is bugged!');
|
||||
});
|
||||
|
||||
|
|
@ -184,6 +184,6 @@ test('should retry worker fixture setup failure', async ({ runInlineTest }) => {
|
|||
expect(result.exitCode).toBe(1);
|
||||
expect(result.passed).toBe(0);
|
||||
expect(result.failed).toBe(1);
|
||||
expect(stripAscii(result.output).split('\n')[0]).toBe('××F');
|
||||
expect(stripAscii(result.output).split('\n')[2]).toBe('××F');
|
||||
expect(result.output).toContain('worker setup is bugged!');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue