playwright-qase-reporter 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,11 +18,13 @@ npm install -D playwright-qase-reporter
18
18
 
19
19
  # Contents
20
20
 
21
- - [Getting started](#getting-started)
22
- - [Updating from v1](#updating-from-v1)
23
- - [Example of usage](#example-of-usage)
24
- - [Configuration](#configuration)
25
- - [Requirements](#requirements)
21
+ - [Qase TMS Playwright reporter](#qase-tms-playwright-reporter)
22
+ - [Contents](#contents)
23
+ - [Getting started](#getting-started)
24
+ - [Updating from v1](#updating-from-v1)
25
+ - [Example of usage](#example-of-usage)
26
+ - [Configuration](#configuration)
27
+ - [Requirements](#requirements)
26
28
 
27
29
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
28
30
 
@@ -172,6 +174,8 @@ Reporter options (\* - required):
172
174
  - `testops.run.title` - Set custom Run name, when new run is created
173
175
  - `testops.run.description` - Set custom Run description, when new run is created
174
176
  - `testops.run.complete` - Whether the run should be completed
177
+ - `framework.browser.addAsParameter` - Whether to add the browser name as a parameter, default - `false`
178
+ - `framework.browser.parameterName` - The name of the parameter to add the browser name to, default - `browser`
175
179
 
176
180
  Example `playwright.config.js` config:
177
181
 
@@ -197,6 +201,12 @@ const config = {
197
201
  complete: true,
198
202
  },
199
203
  },
204
+ framework: {
205
+ browser: {
206
+ addAsParameter: true,
207
+ parameterName: 'Browser Name',
208
+ },
209
+ },
200
210
  },
201
211
  ],
202
212
  ],
package/changelog.md CHANGED
@@ -1,3 +1,28 @@
1
+ # playwright-qase-reporter@2.1.3
2
+
3
+ ## What's new
4
+
5
+ Support specifying the browser name as a parameter.
6
+ New section `framework` was added to the playwright config.
7
+
8
+ ```ts
9
+ [
10
+ 'playwright-qase-reporter',
11
+ {
12
+ debug: true,
13
+ testops: {
14
+ ...
15
+ },
16
+ framework: {
17
+ browser: {
18
+ addAsParameter: true,
19
+ parameterName: 'Browser Name',
20
+ },
21
+ },
22
+ },
23
+ ],
24
+ ```
25
+
1
26
  # playwright-qase-reporter@2.1.1
2
27
 
3
28
  ## What's new
@@ -0,0 +1,4 @@
1
+ import { JSONSchemaType } from 'ajv';
2
+ import { FrameworkOptionsType } from 'qase-javascript-commons';
3
+ import { ReporterOptionsType } from './options';
4
+ export declare const configSchema: JSONSchemaType<FrameworkOptionsType<'playwright', ReporterOptionsType>>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configSchema = void 0;
4
+ exports.configSchema = {
5
+ type: 'object',
6
+ nullable: true,
7
+ properties: {
8
+ framework: {
9
+ type: 'object',
10
+ nullable: true,
11
+ properties: {
12
+ playwright: {
13
+ type: 'object',
14
+ nullable: true,
15
+ properties: {
16
+ browser: {
17
+ type: 'object',
18
+ nullable: true,
19
+ properties: {
20
+ addAsParameter: {
21
+ type: 'boolean',
22
+ nullable: true,
23
+ },
24
+ parameterName: {
25
+ type: 'string',
26
+ nullable: true,
27
+ },
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ };
@@ -0,0 +1,6 @@
1
+ export type ReporterOptionsType = {
2
+ browser?: {
3
+ addAsParameter?: boolean;
4
+ parameterName?: string;
5
+ };
6
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,9 @@
1
1
  import { Reporter, TestCase, TestResult, TestStatus, TestStep } from '@playwright/test/reporter';
2
2
  import { ConfigLoader, ConfigType, TestStatusEnum } from 'qase-javascript-commons';
3
- export type PlaywrightQaseOptionsType = ConfigType;
3
+ import { ReporterOptionsType } from './options';
4
+ export type PlaywrightQaseOptionsType = Omit<ConfigType, 'reporterOptions'> & {
5
+ framework: ReporterOptionsType;
6
+ };
4
7
  /**
5
8
  * @class PlaywrightQaseReporter
6
9
  * @implements Reporter
@@ -55,6 +58,7 @@ export declare class PlaywrightQaseReporter implements Reporter {
55
58
  * @private
56
59
  */
57
60
  private reporter;
61
+ private options;
58
62
  /**
59
63
  * @param {PlaywrightQaseOptionsType} options
60
64
  * @param {ConfigLoaderInterface} configLoader
@@ -84,13 +88,6 @@ export declare class PlaywrightQaseReporter implements Reporter {
84
88
  * @private
85
89
  */
86
90
  private convertLogsToAttachments;
87
- /**
88
- * @param {string[]} suites
89
- * @param {Record<string, string>} parameters
90
- * @param {number[]} ids
91
- * @private
92
- */
93
- private getSignature;
94
91
  /**
95
92
  * @param {string} title
96
93
  * @returns {string}
package/dist/reporter.js CHANGED
@@ -242,14 +242,17 @@ class PlaywrightQaseReporter {
242
242
  * @private
243
243
  */
244
244
  reporter;
245
+ options;
245
246
  /**
246
247
  * @param {PlaywrightQaseOptionsType} options
247
248
  * @param {ConfigLoaderInterface} configLoader
248
249
  */
249
250
  constructor(options, configLoader = new qase_javascript_commons_1.ConfigLoader()) {
250
251
  const config = configLoader.load();
252
+ const { framework, ...composedOptions } = (0, qase_javascript_commons_1.composeOptions)(options, config);
253
+ this.options = options.framework ?? {};
251
254
  this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
252
- ...(0, qase_javascript_commons_1.composeOptions)(options, config),
255
+ ...composedOptions,
253
256
  frameworkPackage: '@playwright/test',
254
257
  frameworkName: 'playwright',
255
258
  reporterName: 'playwright-qase-reporter',
@@ -283,7 +286,7 @@ class PlaywrightQaseReporter {
283
286
  }
284
287
  const error = result.error ? PlaywrightQaseReporter.transformError(result.errors) : null;
285
288
  const extractedSuites = this.extractSuiteFromAnnotation(test.annotations);
286
- const suites = extractedSuites.length > 0
289
+ let suites = extractedSuites.length > 0
287
290
  ? extractedSuites
288
291
  : (testCaseMetadata.suite ? [testCaseMetadata.suite] : PlaywrightQaseReporter.transformSuiteTitle(test));
289
292
  let message = null;
@@ -299,6 +302,15 @@ class PlaywrightQaseReporter {
299
302
  }
300
303
  message += error.message;
301
304
  }
305
+ if (this.options.browser?.addAsParameter) {
306
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
307
+ const browser = test._projectId ?? null;
308
+ if (browser) {
309
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
310
+ testCaseMetadata.parameters[this.options.browser?.parameterName ?? 'browser'] = browser;
311
+ suites = suites.filter(suite => suite !== browser);
312
+ }
313
+ }
302
314
  const testTitle = this.removeQaseIdsFromTitle(test.title);
303
315
  const testResult = {
304
316
  attachments: testCaseMetadata.attachments,
@@ -355,7 +367,7 @@ class PlaywrightQaseReporter {
355
367
  else {
356
368
  testResult.testops_id = PlaywrightQaseReporter.qaseIds.get(test.title) ?? null;
357
369
  }
358
- testResult.signature = this.getSignature(suites, testCaseMetadata.parameters, testResult.testops_id ?? []);
370
+ testResult.signature = (0, qase_javascript_commons_1.generateSignature)(testResult.testops_id, suites, testCaseMetadata.parameters);
359
371
  await this.reporter.addTestResult(testResult);
360
372
  }
361
373
  /**
@@ -385,27 +397,6 @@ class PlaywrightQaseReporter {
385
397
  content: content,
386
398
  };
387
399
  }
388
- /**
389
- * @param {string[]} suites
390
- * @param {Record<string, string>} parameters
391
- * @param {number[]} ids
392
- * @private
393
- */
394
- getSignature(suites, parameters, ids) {
395
- let signature = suites.map(suite => suite.toLowerCase()
396
- .replace('/', '::')
397
- .replace(/\s/g, '_')).join('::');
398
- if (ids.length > 0) {
399
- signature += '::' + ids.join('::');
400
- }
401
- if (Object.keys(parameters).length !== 0) {
402
- signature += '::';
403
- }
404
- signature += Object.entries(parameters)
405
- .map(([key, value]) => `{${key}:${value}}`)
406
- .join('::');
407
- return signature;
408
- }
409
400
  /**
410
401
  * @param {string} title
411
402
  * @returns {string}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright-qase-reporter",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Qase TMS Playwright Reporter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "license": "Apache-2.0",
45
45
  "dependencies": {
46
46
  "chalk": "^4.1.2",
47
- "qase-javascript-commons": "~2.3.0",
47
+ "qase-javascript-commons": "~2.3.3",
48
48
  "uuid": "^9.0.0"
49
49
  },
50
50
  "peerDependencies": {
@@ -53,6 +53,7 @@
53
53
  "devDependencies": {
54
54
  "@jest/globals": "^29.5.0",
55
55
  "@types/jest": "^29.5.2",
56
+ "ajv": "^8.12.0",
56
57
  "jest": "^29.5.0",
57
58
  "ts-jest": "^29.1.0"
58
59
  }