qase-javascript-commons 2.4.4 → 2.4.5

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
@@ -40,6 +40,7 @@ All configuration options are listed in the table below:
40
40
  | Root suite | `rootSuite` | `QASE_ROOT_SUITE` | undefined | No | Any string |
41
41
  | Enable debug logs | `debug` | `QASE_DEBUG` | `False` | No | `True`, `False` |
42
42
  | Enable capture logs from `stdout` and `stderr` | `testops.defect` | `QASE_CAPTURE_LOGS` | `False` | No | `True`, `False` |
43
+ | Map test result statuses to different values (format: `fromStatus=toStatus`) | `statusMapping` | `QASE_STATUS_MAPPING` | undefined | No | Object mapping statuses (e.g., `{"invalid": "failed", "skipped": "passed"}`) |
43
44
  | **Qase Report configuration** | | | | | |
44
45
  | Driver used for report mode | `report.driver` | `QASE_REPORT_DRIVER` | `local` | No | `local` |
45
46
  | Path to save the report | `report.connection.path` | `QASE_REPORT_CONNECTION_PATH` | `./build/qase-report` | | |
@@ -72,6 +73,10 @@ All configuration options are listed in the table below:
72
73
  "debug": false,
73
74
  "environment": "local",
74
75
  "captureLogs": false,
76
+ "statusMapping": {
77
+ "invalid": "failed",
78
+ "skipped": "passed"
79
+ },
75
80
  "report": {
76
81
  "driver": "local",
77
82
  "connection": {
@@ -131,4 +136,7 @@ export QASE_TESTOPS_RUN_EXTERNAL_LINK='{"type":"jiraServer","link":"PROJ-456"}'
131
136
 
132
137
  # Filter out test results with specific statuses
133
138
  export QASE_TESTOPS_STATUS_FILTER="passed,failed"
139
+
140
+ # Map test result statuses
141
+ export QASE_STATUS_MAPPING="invalid=failed,skipped=passed"
134
142
  ```
package/changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ # qase-javascript-commons@2.4.5
2
+
3
+ ## What's new
4
+
5
+ Added support for status mapping in the test run.
6
+ You can now map test result statuses to different values.
7
+
1
8
  # qase-javascript-commons@2.4.4
2
9
 
3
10
  ## What's new
@@ -33,6 +33,13 @@ export declare const configValidationSchema: {
33
33
  type: string;
34
34
  nullable: boolean;
35
35
  };
36
+ statusMapping: {
37
+ type: string;
38
+ nullable: boolean;
39
+ additionalProperties: {
40
+ type: string;
41
+ };
42
+ };
36
43
  testops: {
37
44
  type: string;
38
45
  nullable: boolean;
@@ -36,6 +36,13 @@ exports.configValidationSchema = {
36
36
  type: 'string',
37
37
  nullable: true,
38
38
  },
39
+ statusMapping: {
40
+ type: 'object',
41
+ nullable: true,
42
+ additionalProperties: {
43
+ type: 'string',
44
+ },
45
+ },
39
46
  testops: {
40
47
  type: 'object',
41
48
  nullable: true,
@@ -7,7 +7,8 @@ export declare enum EnvEnum {
7
7
  debug = "QASE_DEBUG",
8
8
  environment = "QASE_ENVIRONMENT",
9
9
  captureLogs = "QASE_CAPTURE_LOGS",
10
- rootSuite = "QASE_ROOT_SUITE"
10
+ rootSuite = "QASE_ROOT_SUITE",
11
+ statusMapping = "QASE_STATUS_MAPPING"
11
12
  }
12
13
  /**
13
14
  * @enum {string}
@@ -12,6 +12,7 @@ var EnvEnum;
12
12
  EnvEnum["environment"] = "QASE_ENVIRONMENT";
13
13
  EnvEnum["captureLogs"] = "QASE_CAPTURE_LOGS";
14
14
  EnvEnum["rootSuite"] = "QASE_ROOT_SUITE";
15
+ EnvEnum["statusMapping"] = "QASE_STATUS_MAPPING";
15
16
  })(EnvEnum || (exports.EnvEnum = EnvEnum = {}));
16
17
  /**
17
18
  * @enum {string}
@@ -13,6 +13,11 @@ const envToConfig = (env) => ({
13
13
  environment: env[env_enum_1.EnvEnum.environment],
14
14
  captureLogs: env[env_enum_1.EnvEnum.captureLogs],
15
15
  rootSuite: env[env_enum_1.EnvEnum.rootSuite],
16
+ statusMapping: env[env_enum_1.EnvEnum.statusMapping] ?
17
+ Object.fromEntries(env[env_enum_1.EnvEnum.statusMapping].split(',').map(item => {
18
+ const [from, to] = item.split('=');
19
+ return [from?.trim() || '', to?.trim() || ''];
20
+ })) : undefined,
16
21
  testops: {
17
22
  project: env[env_enum_1.EnvTestOpsEnum.project],
18
23
  uploadAttachments: env[env_enum_1.EnvTestOpsEnum.uploadAttachments],
@@ -8,6 +8,7 @@ export interface EnvType {
8
8
  [EnvEnum.environment]?: string;
9
9
  [EnvEnum.captureLogs]?: boolean;
10
10
  [EnvEnum.rootSuite]?: string;
11
+ [EnvEnum.statusMapping]?: string;
11
12
  [EnvTestOpsEnum.project]?: string;
12
13
  [EnvTestOpsEnum.uploadAttachments]?: boolean;
13
14
  [EnvTestOpsEnum.defect]?: boolean;
@@ -36,6 +36,10 @@ exports.envValidationSchema = {
36
36
  type: 'string',
37
37
  nullable: true,
38
38
  },
39
+ [env_enum_1.EnvEnum.statusMapping]: {
40
+ type: 'string',
41
+ nullable: true,
42
+ },
39
43
  [env_enum_1.EnvTestOpsEnum.project]: {
40
44
  type: 'string',
41
45
  nullable: true,
@@ -21,6 +21,7 @@ export type OptionsType = {
21
21
  debug?: boolean | undefined;
22
22
  environment?: string | undefined;
23
23
  rootSuite?: string | undefined;
24
+ statusMapping?: Record<string, string> | undefined;
24
25
  testops?: RecursivePartial<TestOpsOptionsType> | undefined;
25
26
  report?: RecursivePartial<AdditionalReportOptionsType> | undefined;
26
27
  };
package/dist/qase.d.ts CHANGED
@@ -65,6 +65,11 @@ export declare class QaseReporter implements ReporterInterface {
65
65
  * @returns {QaseReporter}
66
66
  */
67
67
  static getInstance(options: OptionsType): QaseReporter;
68
+ /**
69
+ * Get status mapping configuration
70
+ * @returns Status mapping configuration or undefined
71
+ */
72
+ getStatusMapping(): Record<string, string> | undefined;
68
73
  /**
69
74
  * @param {TestResultType} result
70
75
  */
package/dist/qase.js CHANGED
@@ -16,6 +16,7 @@ const logger_1 = require("./utils/logger");
16
16
  const state_1 = require("./state/state");
17
17
  const hostData_1 = require("./utils/hostData");
18
18
  const clientV2_1 = require("./client/clientV2");
19
+ const status_mapping_utils_1 = require("./utils/status-mapping-utils");
19
20
  /**
20
21
  * @type {Record<TestStatusEnum, (test: TestResultType) => string>}
21
22
  */
@@ -276,11 +277,28 @@ class QaseReporter {
276
277
  }
277
278
  return QaseReporter.instance;
278
279
  }
280
+ /**
281
+ * Get status mapping configuration
282
+ * @returns Status mapping configuration or undefined
283
+ */
284
+ getStatusMapping() {
285
+ return this.options.statusMapping;
286
+ }
279
287
  /**
280
288
  * @param {TestResultType} result
281
289
  */
282
290
  async addTestResult(result) {
283
291
  if (!this.disabled) {
292
+ // Apply status mapping if configured
293
+ const statusMapping = this.getStatusMapping();
294
+ if (statusMapping) {
295
+ const originalStatus = result.execution.status;
296
+ const mappedStatus = (0, status_mapping_utils_1.applyStatusMapping)(originalStatus, statusMapping);
297
+ if (mappedStatus !== originalStatus) {
298
+ this.logger.logDebug(`Status mapping applied: ${originalStatus} -> ${mappedStatus}`);
299
+ result.execution.status = mappedStatus;
300
+ }
301
+ }
284
302
  // Check if result should be filtered out based on status
285
303
  if (this.shouldFilterResult(result)) {
286
304
  this.logger.logDebug(`Filtering out test result with status: ${result.execution.status}`);
@@ -0,0 +1,14 @@
1
+ import { TestStatusEnum } from '../models/test-execution';
2
+ /**
3
+ * Applies status mapping configuration to a test status
4
+ * @param status - Original test status
5
+ * @param statusMapping - Status mapping configuration
6
+ * @returns Mapped test status or original if no mapping found
7
+ */
8
+ export declare function applyStatusMapping(status: TestStatusEnum, statusMapping?: Record<string, string>): TestStatusEnum;
9
+ /**
10
+ * Validates status mapping configuration
11
+ * @param statusMapping - Status mapping configuration to validate
12
+ * @returns Array of validation errors (empty if valid)
13
+ */
14
+ export declare function validateStatusMapping(statusMapping: Record<string, string>): string[];
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateStatusMapping = exports.applyStatusMapping = void 0;
4
+ const test_execution_1 = require("../models/test-execution");
5
+ /**
6
+ * Applies status mapping configuration to a test status
7
+ * @param status - Original test status
8
+ * @param statusMapping - Status mapping configuration
9
+ * @returns Mapped test status or original if no mapping found
10
+ */
11
+ function applyStatusMapping(status, statusMapping) {
12
+ if (!statusMapping) {
13
+ return status;
14
+ }
15
+ const mappedStatus = statusMapping[status];
16
+ if (!mappedStatus) {
17
+ return status;
18
+ }
19
+ // Validate that the mapped status is a valid TestStatusEnum value
20
+ const validStatuses = Object.values(test_execution_1.TestStatusEnum);
21
+ if (!validStatuses.includes(mappedStatus)) {
22
+ console.warn(`Invalid status mapping: "${status}" -> "${mappedStatus}". Valid statuses are: ${validStatuses.join(', ')}`);
23
+ return status;
24
+ }
25
+ return mappedStatus;
26
+ }
27
+ exports.applyStatusMapping = applyStatusMapping;
28
+ /**
29
+ * Validates status mapping configuration
30
+ * @param statusMapping - Status mapping configuration to validate
31
+ * @returns Array of validation errors (empty if valid)
32
+ */
33
+ function validateStatusMapping(statusMapping) {
34
+ const errors = [];
35
+ const validStatuses = Object.values(test_execution_1.TestStatusEnum);
36
+ for (const [fromStatus, toStatus] of Object.entries(statusMapping)) {
37
+ if (!validStatuses.includes(fromStatus)) {
38
+ errors.push(`Invalid source status "${fromStatus}". Valid statuses are: ${validStatuses.join(', ')}`);
39
+ }
40
+ if (!validStatuses.includes(toStatus)) {
41
+ errors.push(`Invalid target status "${toStatus}". Valid statuses are: ${validStatuses.join(', ')}`);
42
+ }
43
+ }
44
+ return errors;
45
+ }
46
+ exports.validateStatusMapping = validateStatusMapping;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qase-javascript-commons",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "Qase JS Reporters",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",