qase-javascript-commons 2.4.3 → 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 +8 -0
- package/changelog.md +13 -0
- package/dist/client/clientV1.js +2 -2
- package/dist/config/config-validation-schema.d.ts +7 -0
- package/dist/config/config-validation-schema.js +7 -0
- package/dist/env/env-enum.d.ts +2 -1
- package/dist/env/env-enum.js +1 -0
- package/dist/env/env-to-config.js +5 -0
- package/dist/env/env-type.d.ts +1 -0
- package/dist/env/env-validation-schema.js +4 -0
- package/dist/options/options-type.d.ts +1 -0
- package/dist/qase.d.ts +5 -0
- package/dist/qase.js +18 -0
- package/dist/utils/status-mapping-utils.d.ts +14 -0
- package/dist/utils/status-mapping-utils.js +46 -0
- package/package.json +3 -3
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,16 @@
|
|
|
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
|
+
|
|
8
|
+
# qase-javascript-commons@2.4.4
|
|
9
|
+
|
|
10
|
+
## What's new
|
|
11
|
+
|
|
12
|
+
Updated the `qase-api-client` dependency to version `1.0.6`.
|
|
13
|
+
|
|
1
14
|
# qase-javascript-commons@2.4.3
|
|
2
15
|
|
|
3
16
|
## What's new
|
package/dist/client/clientV1.js
CHANGED
|
@@ -78,8 +78,8 @@ class ClientV1 {
|
|
|
78
78
|
// Map our enum values to API enum values
|
|
79
79
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
|
80
80
|
const apiType = this.config.run.externalLink.type === 'jiraCloud'
|
|
81
|
-
? qase_api_client_1.
|
|
82
|
-
: qase_api_client_1.
|
|
81
|
+
? qase_api_client_1.RunExternalIssuesTypeEnum.JIRA_CLOUD
|
|
82
|
+
: qase_api_client_1.RunExternalIssuesTypeEnum.JIRA_SERVER;
|
|
83
83
|
await this.runClient.runUpdateExternalIssue(this.config.project, {
|
|
84
84
|
type: apiType,
|
|
85
85
|
links: [
|
|
@@ -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;
|
package/dist/env/env-enum.d.ts
CHANGED
|
@@ -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}
|
package/dist/env/env-enum.js
CHANGED
|
@@ -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],
|
package/dist/env/env-type.d.ts
CHANGED
|
@@ -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;
|
|
@@ -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.
|
|
3
|
+
"version": "2.4.5",
|
|
4
4
|
"description": "Qase JS Reporters",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"lodash.merge": "^4.6.2",
|
|
34
34
|
"lodash.mergewith": "^4.6.2",
|
|
35
35
|
"mime-types": "^2.1.33",
|
|
36
|
-
"qase-api-client": "~1.0
|
|
36
|
+
"qase-api-client": "~1.1.0",
|
|
37
37
|
"qase-api-v2-client": "~1.0.1",
|
|
38
38
|
"strip-ansi": "^6.0.1",
|
|
39
39
|
"uuid": "^9.0.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/mime-types": "^2.1.4",
|
|
48
48
|
"@types/node": "^20.12.5",
|
|
49
49
|
"@types/uuid": "^9.0.1",
|
|
50
|
-
"axios": "^1.
|
|
50
|
+
"axios": "^1.12.0",
|
|
51
51
|
"jest": "^29.5.0",
|
|
52
52
|
"ts-jest": "^29.1.0"
|
|
53
53
|
}
|