@reportportal/client-javascript 5.1.1 → 5.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 +10 -9
- package/VERSION +1 -1
- package/lib/constants/outputs.js +7 -2
- package/lib/helpers.js +9 -0
- package/lib/report-portal-client.js +27 -16
- package/package.json +4 -4
- package/lib/polyfills.js +0 -19
package/README.md
CHANGED
|
@@ -6,17 +6,18 @@ Library is used only for implementors of custom listeners for ReportPortal.
|
|
|
6
6
|
|
|
7
7
|
## Already implemented listeners:
|
|
8
8
|
|
|
9
|
-
* [
|
|
9
|
+
* [Playwright integration](https://github.com/reportportal/agent-js-playwright)
|
|
10
10
|
* [Cypress integration](https://github.com/reportportal/agent-js-cypress)
|
|
11
|
+
* [Jest integration](https://github.com/reportportal/agent-js-jest)
|
|
11
12
|
* [Mocha integration](https://github.com/reportportal/agent-js-mocha)
|
|
12
|
-
* [
|
|
13
|
-
* [Nightwatch integration](https://github.com/reportportal/agent-js-nightwatch)
|
|
14
|
-
* [Cucumber integration](https://github.com/reportportal/agent-js-cucumber)
|
|
15
|
-
* [Codecept integration](https://github.com/reportportal/agent-js-codecept)
|
|
13
|
+
* [Webdriverio integration](https://github.com/reportportal/agent-js-webdriverio)
|
|
16
14
|
* [Postman integration](https://github.com/reportportal/agent-js-postman)
|
|
15
|
+
* [Cucumber integration](https://github.com/reportportal/agent-js-cucumber)
|
|
16
|
+
* [Vitest integration](https://github.com/reportportal/agent-js-vitest)
|
|
17
|
+
* [Jasmine integration](https://github.com/reportportal/agent-js-jasmine)
|
|
17
18
|
* [TestCafe integration](https://github.com/reportportal/agent-js-testcafe)
|
|
18
|
-
* [
|
|
19
|
-
* [
|
|
19
|
+
* [Codecept integration](https://github.com/reportportal/agent-js-codecept)
|
|
20
|
+
* [Nightwatch integration](https://github.com/reportportal/agent-js-nightwatch)
|
|
20
21
|
|
|
21
22
|
Examples for test framework integrations from the list above described in [examples](https://github.com/reportportal/examples-js) repository.
|
|
22
23
|
|
|
@@ -61,9 +62,9 @@ When creating a client instance, you need to specify the following options:
|
|
|
61
62
|
| headers | Optional | {} | The object with custom headers for internal http client. |
|
|
62
63
|
| debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
|
|
63
64
|
| isLaunchMergeRequired | Optional | false | Allows client to merge launches into one at the end of the run via saving their UUIDs to the temp files at filesystem . At the end of the run launches can be merged using `mergeLaunches` method. Temp file format: `rplaunch-${launch_uuid}.tmp`. |
|
|
64
|
-
| restClientConfig | Optional | Not set |
|
|
65
|
+
| restClientConfig | Optional | Not set | `axios` like http client [config](https://github.com/axios/axios#request-config). May contain `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, and other client options eg. `timeout`. For debugging and displaying logs you can set `debug: true`. |
|
|
65
66
|
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
|
|
66
|
-
| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if `launchUuidPrint` set to `true`.
|
|
67
|
+
| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR', 'FILE', 'ENVIRONMENT'. Works only if `launchUuidPrint` set to `true`. File format: `rp-launch-uuid-${launch_uuid}.tmp`. Env variable: `RP_LAUNCH_UUID`. |
|
|
67
68
|
| token | Deprecated | Not set | Use `apiKey` instead. |
|
|
68
69
|
|
|
69
70
|
## Asynchronous reporting
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.1.
|
|
1
|
+
5.1.4-SNAPSHOT
|
package/lib/constants/outputs.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
const helpers = require('../helpers');
|
|
2
|
+
|
|
1
3
|
const OUTPUT_TYPES = {
|
|
2
4
|
// eslint-disable-next-line no-console
|
|
3
|
-
STDOUT: console.log,
|
|
5
|
+
STDOUT: (launchUuid) => console.log(`Report Portal Launch UUID: ${launchUuid}`),
|
|
4
6
|
// eslint-disable-next-line no-console
|
|
5
|
-
STDERR: console.error,
|
|
7
|
+
STDERR: (launchUuid) => console.error(`Report Portal Launch UUID: ${launchUuid}`),
|
|
8
|
+
// eslint-disable-next-line no-return-assign
|
|
9
|
+
ENVIRONMENT: (launchUuid) => (process.env.RP_LAUNCH_UUID = launchUuid),
|
|
10
|
+
FILE: helpers.saveLaunchUuidToFile,
|
|
6
11
|
};
|
|
7
12
|
|
|
8
13
|
module.exports = { OUTPUT_TYPES };
|
package/lib/helpers.js
CHANGED
|
@@ -89,4 +89,13 @@ module.exports = {
|
|
|
89
89
|
|
|
90
90
|
return `${codeRef}[${parameters}]`;
|
|
91
91
|
},
|
|
92
|
+
|
|
93
|
+
saveLaunchUuidToFile(launchUuid) {
|
|
94
|
+
const filename = `rp-launch-uuid-${launchUuid}.tmp`;
|
|
95
|
+
fs.open(filename, 'w', (err) => {
|
|
96
|
+
if (err) {
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
},
|
|
92
101
|
};
|
|
@@ -7,7 +7,6 @@ const { getClientConfig } = require('./commons/config');
|
|
|
7
7
|
const Statistics = require('../statistics/statistics');
|
|
8
8
|
const { EVENT_NAME } = require('../statistics/constants');
|
|
9
9
|
const { RP_STATUSES } = require('./constants/statuses');
|
|
10
|
-
require('./polyfills');
|
|
11
10
|
|
|
12
11
|
const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString();
|
|
13
12
|
|
|
@@ -53,7 +52,8 @@ class RPClient {
|
|
|
53
52
|
});
|
|
54
53
|
this.statistics = new Statistics(EVENT_NAME, agentParams);
|
|
55
54
|
this.launchUuid = '';
|
|
56
|
-
this.
|
|
55
|
+
this.itemRetriesChainMap = new Map();
|
|
56
|
+
this.itemRetriesChainKeyMapByTempId = new Map();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// eslint-disable-next-line valid-jsdoc
|
|
@@ -67,10 +67,27 @@ class RPClient {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
calculateItemRetriesChainMapKey(launchId, parentId, name, itemId = '') {
|
|
71
71
|
return `${launchId}__${parentId}__${name}__${itemId}`;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// eslint-disable-next-line valid-jsdoc
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @Private
|
|
78
|
+
*/
|
|
79
|
+
cleanItemRetriesChain(tempIds) {
|
|
80
|
+
tempIds.forEach((id) => {
|
|
81
|
+
const key = this.itemRetriesChainKeyMapByTempId.get(id);
|
|
82
|
+
|
|
83
|
+
if (key) {
|
|
84
|
+
this.itemRetriesChainMap.delete(key);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.itemRetriesChainKeyMapByTempId.delete(id);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
74
91
|
getUniqId() {
|
|
75
92
|
return UniqId();
|
|
76
93
|
}
|
|
@@ -189,7 +206,7 @@ class RPClient {
|
|
|
189
206
|
this.map[tempId].realId = response.id;
|
|
190
207
|
this.launchUuid = response.id;
|
|
191
208
|
if (this.config.launchUuidPrint) {
|
|
192
|
-
this.config.launchUuidPrintOutput(
|
|
209
|
+
this.config.launchUuidPrintOutput(this.launchUuid);
|
|
193
210
|
}
|
|
194
211
|
|
|
195
212
|
if (this.isLaunchMergeRequired) {
|
|
@@ -488,20 +505,17 @@ class RPClient {
|
|
|
488
505
|
parentPromise = parentObj.promiseStart;
|
|
489
506
|
}
|
|
490
507
|
|
|
491
|
-
const itemKey = this.
|
|
508
|
+
const itemKey = this.calculateItemRetriesChainMapKey(
|
|
492
509
|
launchTempId,
|
|
493
510
|
parentTempId,
|
|
494
511
|
testItemDataRQ.name,
|
|
495
512
|
testItemDataRQ.uniqueId,
|
|
496
513
|
);
|
|
497
|
-
const
|
|
498
|
-
if (firstNonRetriedItemPromise) {
|
|
499
|
-
parentPromise = Promise.all([parentPromise, firstNonRetriedItemPromise]);
|
|
500
|
-
}
|
|
514
|
+
const executionItemPromise = testItemDataRQ.retry && this.itemRetriesChainMap.get(itemKey);
|
|
501
515
|
|
|
502
516
|
const tempId = this.getUniqId();
|
|
503
517
|
this.map[tempId] = this.getNewItemObj((resolve, reject) => {
|
|
504
|
-
parentPromise.then(
|
|
518
|
+
(executionItemPromise || parentPromise).then(
|
|
505
519
|
() => {
|
|
506
520
|
const realLaunchId = this.map[launchTempId].realId;
|
|
507
521
|
let url = 'item/';
|
|
@@ -515,7 +529,6 @@ class RPClient {
|
|
|
515
529
|
(response) => {
|
|
516
530
|
this.logDebug(`Success start item with tempId ${tempId}`, response);
|
|
517
531
|
this.map[tempId].realId = response.id;
|
|
518
|
-
this.nonRetriedItemMap.delete(itemKey);
|
|
519
532
|
resolve(response);
|
|
520
533
|
},
|
|
521
534
|
(error) => {
|
|
@@ -531,10 +544,8 @@ class RPClient {
|
|
|
531
544
|
);
|
|
532
545
|
});
|
|
533
546
|
this.map[parentMapId].children.push(tempId);
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
this.nonRetriedItemMap.set(itemKey, this.map[tempId].promiseStart);
|
|
537
|
-
}
|
|
547
|
+
this.itemRetriesChainKeyMapByTempId.set(tempId, itemKey);
|
|
548
|
+
this.itemRetriesChainMap.set(itemKey, this.map[tempId].promiseStart);
|
|
538
549
|
|
|
539
550
|
return {
|
|
540
551
|
tempId,
|
|
@@ -602,7 +613,7 @@ class RPClient {
|
|
|
602
613
|
}
|
|
603
614
|
});
|
|
604
615
|
}
|
|
605
|
-
|
|
616
|
+
this.cleanItemRetriesChain(itemObj.children);
|
|
606
617
|
this.cleanMap(itemObj.children);
|
|
607
618
|
|
|
608
619
|
this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reportportal/client-javascript",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3",
|
|
4
4
|
"description": "ReportPortal client for Node.js",
|
|
5
5
|
"author": "ReportPortal.io",
|
|
6
6
|
"scripts": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"node": ">=12.x"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^1.6.
|
|
28
|
-
"axios-retry": "^4.
|
|
29
|
-
"glob": "^
|
|
27
|
+
"axios": "^1.6.8",
|
|
28
|
+
"axios-retry": "^4.1.0",
|
|
29
|
+
"glob": "^8.1.0",
|
|
30
30
|
"ini": "^2.0.0",
|
|
31
31
|
"uniqid": "^5.4.0",
|
|
32
32
|
"uuid": "^9.0.1"
|
package/lib/polyfills.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//! Was added to support NodeJS 10.
|
|
2
|
-
if (!Promise.allSettled) {
|
|
3
|
-
Promise.allSettled = function (promises) {
|
|
4
|
-
return Promise.all(
|
|
5
|
-
promises.map((p) =>
|
|
6
|
-
Promise.resolve(p).then(
|
|
7
|
-
(value) => ({
|
|
8
|
-
status: 'fulfilled',
|
|
9
|
-
value,
|
|
10
|
-
}),
|
|
11
|
-
(error) => ({
|
|
12
|
-
status: 'rejected',
|
|
13
|
-
reason: error,
|
|
14
|
-
}),
|
|
15
|
-
),
|
|
16
|
-
),
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
}
|