From bf24ddf126e88420cb50c6f3164e6b025c566b5d Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Mon, 10 Jun 2024 15:02:20 +0200 Subject: [PATCH] release: qase-playwright 2.0.3 Added new annotation `qase.suite()`. Tests marked with it will be grouped in the Qase report by the specified suite name. --- qase-playwright/changelog.md | 14 ++++++++++++++ qase-playwright/package.json | 2 +- qase-playwright/src/playwright.ts | 17 +++++++++++++++++ qase-playwright/src/reporter.ts | 8 +++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/qase-playwright/changelog.md b/qase-playwright/changelog.md index 699fa75f..6444a4d0 100644 --- a/qase-playwright/changelog.md +++ b/qase-playwright/changelog.md @@ -1,3 +1,17 @@ +# playwright-qase-reporter@2.0.3 + +## What's new + +Added new annotation `qase.suite()`. +Tests marked with it will be grouped in the Qase report by the specified suite name. + +```js +test('test', async ({ page }) => { + qase.suite("Custom suite"); + await page.goto('https://example.com'); +}); +``` + # playwright-qase-reporter@2.0.2 ## What's new diff --git a/qase-playwright/package.json b/qase-playwright/package.json index 970b1a44..2ae0699f 100644 --- a/qase-playwright/package.json +++ b/qase-playwright/package.json @@ -1,6 +1,6 @@ { "name": "playwright-qase-reporter", - "version": "2.0.2", + "version": "2.0.3", "description": "Qase TMS Playwright Reporter", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/qase-playwright/src/playwright.ts b/qase-playwright/src/playwright.ts index 000f5569..79786fb5 100644 --- a/qase-playwright/src/playwright.ts +++ b/qase-playwright/src/playwright.ts @@ -13,6 +13,7 @@ export interface MetadataMessage { fields?: Record; parameters?: Record; ignore?: boolean; + suite?: string; } /** @@ -182,6 +183,22 @@ qase.ignore = function() { return this; }; +/** + * Set a suite for the test case + * @param {string} value + * @example + * test('test', async ({ page }) => { + * qase.suite("Suite"); + * await page.goto('https://example.com'); + * }); + */ +qase.suite = function(value: string) { + addMetadata({ + suite: value, + }); + return this; +}; + const addMetadata = (metadata: MetadataMessage): void => { test.info().attach('qase-metadata.json', { contentType: ReporterContentType, diff --git a/qase-playwright/src/reporter.ts b/qase-playwright/src/reporter.ts index 719e32b1..4efd670d 100644 --- a/qase-playwright/src/reporter.ts +++ b/qase-playwright/src/reporter.ts @@ -30,6 +30,7 @@ interface TestCaseMetadata { parameters: Record; attachments: Attachment[]; ignore: boolean; + suite: string; } export type PlaywrightQaseOptionsType = ConfigType; @@ -98,6 +99,7 @@ export class PlaywrightQaseReporter implements Reporter { parameters: {}, attachments: [], ignore: false, + suite: '', }; const attachments: Attachment[] = []; @@ -131,6 +133,10 @@ export class PlaywrightQaseReporter implements Reporter { metadata.ignore = message.ignore; } + if (message.suite) { + metadata.suite = message.suite; + } + continue; } @@ -307,7 +313,7 @@ export class PlaywrightQaseReporter implements Reporter { } const error = result.error ? PlaywrightQaseReporter.transformError(result.error) : null; - const suites = PlaywrightQaseReporter.transformSuiteTitle(test); + const suites = testCaseMetadata.suite != '' ? [testCaseMetadata.suite] : PlaywrightQaseReporter.transformSuiteTitle(test); const testResult: TestResultType = { attachments: testCaseMetadata.attachments, author: null,