fix(reporter): do not report parallel tests as slow (#11921)
This commit is contained in:
parent
dbd124d84b
commit
8a5c93436d
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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': `
|
||||
|
|
|
|||
Loading…
Reference in a new issue