From de6af16744ec9e95d2540ded00049d9b4e74cfba Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 2 Dec 2021 11:07:45 -0800 Subject: [PATCH] test: add reporter test with grep (#10678) --- tests/playwright-test/reporter.spec.ts | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/playwright-test/reporter.spec.ts b/tests/playwright-test/reporter.spec.ts index a97aa66d15..fbdf7132e5 100644 --- a/tests/playwright-test/reporter.spec.ts +++ b/tests/playwright-test/reporter.spec.ts @@ -478,6 +478,36 @@ test('should report global setup error to reporter', async ({ runInlineTest }) = expect(result.output).toContain(`%%got error: Oh my!`); }); +test('should report correct tests/suites when using grep', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'a.spec.js': ` + const { test } = pwt; + + test.describe('@foo', () => { + test('test1', async ({ }) => { + console.log('%%test1'); + }); + test('test2', async ({ }) => { + console.log('%%test2'); + }); + }); + + test('test3', async ({ }) => { + console.log('%%test3'); + }); + `, + }, { 'grep': '@foo' }); + + expect(result.exitCode).toBe(0); + expect(result.output).toContain('%%test1'); + expect(result.output).toContain('%%test2'); + expect(result.output).not.toContain('%%test3'); + const fileSuite = result.report.suites[0]; + expect(fileSuite.suites.length).toBe(1); + expect(fileSuite.suites[0].specs.length).toBe(2); + expect(fileSuite.specs.length).toBe(0); +}); + function stripEscapedAscii(str: string) { return str.replace(/\\u00[a-z0-9][a-z0-9]\[[^m]+m/g, ''); }