fix(reporter): do not report parallel tests as slow (#11921)

This commit is contained in:
Dmitry Gozman 2022-02-07 20:10:13 -08:00 committed by GitHub
parent dbd124d84b
commit 8a5c93436d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -86,6 +86,11 @@ export class BaseReporter implements Reporter {
}
onTestEnd(test: TestCase, result: TestResult) {
// Ignore any tests that are run in parallel.
for (let suite: Suite | undefined = test.parent; suite; suite = suite.parent) {
if ((suite as any)._parallelMode === 'parallel')
return;
}
const projectName = test.titlePath()[1];
const relativePath = relativeTestPath(this.config, test);
const fileAndProject = (projectName ? `[${projectName}] ` : '') + relativePath;

View file

@ -149,6 +149,30 @@ test('should print slow tests', async ({ runInlineTest }) => {
expect(stripAnsi(result.output)).not.toContain(`Slow test file: [qux] dir${path.sep}b.test.js (`);
});
test('should not print slow parallel tests', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
reportSlowTests: { max: 0, threshold: 500 },
};
`,
'dir/a.test.js': `
const { test } = pwt;
test.describe.parallel('suite', () => {
test('inner slow test', async ({}) => {
await new Promise(f => setTimeout(f, 1000));
});
test('inner fast test', async ({}) => {
await new Promise(f => setTimeout(f, 100));
});
});
`,
});
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(2);
expect(stripAnsi(result.output)).not.toContain('Slow test file');
});
test('should not print slow tests', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `