Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat: addition of tags to JSON reporter output (#8920)
Darrell Breedend82cb9a2ffec
diff --git a/src/test/reporters/json.ts b/src/test/reporters/json.tsindex 71fc7e018e..ae255d617a 100644--- a/src/test/reporters/json.ts+++ b/src/test/reporters/json.ts@@ -44,6 +44,7 @@ export interface JSONReportSuite {suites?: JSONReportSuite[];}export interface JSONReportSpec {+ tags: string[],title: string;ok: boolean;tests: JSONReportTest[];@@ -203,6 +204,7 @@ class JSONReporter implements Reporter {return {title: test.title,ok: test.ok(),+ tags: (test.title.match(/@[\S]+/g) || []).map(t => t.substring(1)),tests: [ this._serializeTest(test) ],...this._relativeLocation(test.location),};diff --git a/tests/playwright-test/json-reporter.spec.ts b/tests/playwright-test/json-reporter.spec.tsindex 62220ee1cb..da280f1c3c 100644--- a/tests/playwright-test/json-reporter.spec.ts+++ b/tests/playwright-test/json-reporter.spec.ts@@ -139,6 +139,35 @@ test('should show steps', async ({ runInlineTest }) => {expect(result.report.suites[0].specs[0].tests[0].results[0].steps[1].error).not.toBeUndefined();});+test('should display tags separately from title', async ({ runInlineTest }) => {+ const result = await runInlineTest({+ 'a.test.js': `+ const { test } = pwt;+ test('math works! @USR-MATH-001 @USR-MATH-002', async ({}) => {+ expect(1 + 1).toBe(2);+ await test.step('math works in a step', async () => {+ expect(2 + 2).toBe(4);+ await test.step('nested step', async () => {+ expect(2 + 2).toBe(4);+ await test.step('deeply nested step', async () => {+ expect(2 + 2).toBe(4);+ });+ })+ })+ });+ `+ });++ expect(result.exitCode).toBe(0);+ expect(result.report.suites.length).toBe(1);+ expect(result.report.suites[0].specs.length).toBe(1);+ // Ensure the length is as expected+ expect(result.report.suites[0].specs[0].tags.length).toBe(2);+ // Ensure that the '@' value is stripped+ expect(result.report.suites[0].specs[0].tags[0]).toBe('USR-MATH-001');+ expect(result.report.suites[0].specs[0].tags[1]).toBe('USR-MATH-002');+});+test('should have relative always-posix paths', async ({ runInlineTest }) => {const result = await runInlineTest({'a.test.js': `