From a24fb36f4a4bf91dc63622929c853a0a30e1325c Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Thu, 6 Jun 2024 15:40:45 +0200 Subject: [PATCH] release: qase-playwright 2.0.2 Added new annotation for test case ignoring `qase.ignore()`. This annotation will mark the test as ignored in the Qase.io test run. --- qase-playwright/README.md | 5 +++++ qase-playwright/changelog.md | 14 ++++++++++++++ qase-playwright/package.json | 4 ++-- qase-playwright/src/playwright.ts | 16 ++++++++++++++++ qase-playwright/src/reporter.ts | 11 +++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/qase-playwright/README.md b/qase-playwright/README.md index 838c88d3..97d5c73a 100644 --- a/qase-playwright/README.md +++ b/qase-playwright/README.md @@ -114,6 +114,11 @@ describe('Test suite', () => { test(qase(2, 'This syntax is still supported'), () => { expect(true).toBe(true); }); + + test('Running, but not reported to Qase', () => { + qase.ignore(); + expect(true).toBe(true); + }); }); ``` diff --git a/qase-playwright/changelog.md b/qase-playwright/changelog.md index c5af1df6..699fa75f 100644 --- a/qase-playwright/changelog.md +++ b/qase-playwright/changelog.md @@ -1,3 +1,17 @@ +# playwright-qase-reporter@2.0.2 + +## What's new + +Added new annotation `qase.ignore()`. +Tests marked with it will run as usual but won't appear in the Qase report. + +```js +test('test', async ({ page }) => { + qase.ignore(); + await page.goto('https://example.com'); +}); +``` + # playwright-qase-reporter@2.0.1 ## What's new diff --git a/qase-playwright/package.json b/qase-playwright/package.json index 0838e26d..970b1a44 100644 --- a/qase-playwright/package.json +++ b/qase-playwright/package.json @@ -1,6 +1,6 @@ { "name": "playwright-qase-reporter", - "version": "2.0.1", + "version": "2.0.2", "description": "Qase TMS Playwright Reporter", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -44,7 +44,7 @@ "license": "Apache-2.0", "dependencies": { "chalk": "^4.1.2", - "qase-javascript-commons": "^2.0.0", + "qase-javascript-commons": "^2.0.8", "uuid": "^9.0.0" }, "peerDependencies": { diff --git a/qase-playwright/src/playwright.ts b/qase-playwright/src/playwright.ts index 056bb91a..000f5569 100644 --- a/qase-playwright/src/playwright.ts +++ b/qase-playwright/src/playwright.ts @@ -12,6 +12,7 @@ export interface MetadataMessage { title?: string; fields?: Record; parameters?: Record; + ignore?: boolean; } /** @@ -166,6 +167,21 @@ qase.attach = function(attach: { return this; }; +/** + * Ignore the test case result in Qase + * @example + * test('test', async ({ page }) => { + * qase.ignore(); + * await page.goto('https://example.com'); + * }); + */ +qase.ignore = function() { + addMetadata({ + ignore: true, + }); + 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 d9829d12..719e32b1 100644 --- a/qase-playwright/src/reporter.ts +++ b/qase-playwright/src/reporter.ts @@ -29,6 +29,7 @@ interface TestCaseMetadata { fields: Record; parameters: Record; attachments: Attachment[]; + ignore: boolean; } export type PlaywrightQaseOptionsType = ConfigType; @@ -96,6 +97,7 @@ export class PlaywrightQaseReporter implements Reporter { fields: {}, parameters: {}, attachments: [], + ignore: false, }; const attachments: Attachment[] = []; @@ -125,6 +127,10 @@ export class PlaywrightQaseReporter implements Reporter { metadata.parameters = message.parameters; } + if (message.ignore) { + metadata.ignore = message.ignore; + } + continue; } @@ -295,6 +301,11 @@ export class PlaywrightQaseReporter implements Reporter { */ public async onTestEnd(test: TestCase, result: TestResult) { const testCaseMetadata = this.transformAttachments(result.attachments); + + if (testCaseMetadata.ignore) { + return; + } + const error = result.error ? PlaywrightQaseReporter.transformError(result.error) : null; const suites = PlaywrightQaseReporter.transformSuiteTitle(test); const testResult: TestResultType = {