Skip to content

Commit

Permalink
release: qase-playwright 2.0.3
Browse files Browse the repository at this point in the history
Added new annotation `qase.suite()`.
Tests marked with it will be grouped in the Qase report by the specified suite name.
  • Loading branch information
gibiw committed Jun 10, 2024
1 parent b73cd60 commit 04d08dc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
14 changes: 14 additions & 0 deletions qase-playwright/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [email protected]

## 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');
});
```

# [email protected]

## What's new
Expand Down
2 changes: 1 addition & 1 deletion qase-playwright/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
17 changes: 17 additions & 0 deletions qase-playwright/src/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface MetadataMessage {
fields?: Record<string, string>;
parameters?: Record<string, string>;
ignore?: boolean;
suite?: string;
}

/**
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion qase-playwright/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface TestCaseMetadata {
parameters: Record<string, string>;
attachments: Attachment[];
ignore: boolean;
suite: string;
}

export type PlaywrightQaseOptionsType = ConfigType;
Expand Down Expand Up @@ -98,6 +99,7 @@ export class PlaywrightQaseReporter implements Reporter {
parameters: {},
attachments: [],
ignore: false,
suite: '',
};
const attachments: Attachment[] = [];

Expand Down Expand Up @@ -131,6 +133,10 @@ export class PlaywrightQaseReporter implements Reporter {
metadata.ignore = message.ignore;
}

if (message.suite) {
metadata.suite = message.suite;
}

continue;
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 04d08dc

Please sign in to comment.