@reportportal/client-javascript 5.0.13 → 5.0.15

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
@@ -52,19 +52,19 @@ rpClient.checkConnect().then((response) => {
52
52
 
53
53
  When creating a client instance, you need to specify the following options:
54
54
 
55
- | Option | Necessity | Default | Description |
56
- |-----------------------|------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
57
- | apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
58
- | endpoint | Required | | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'. |
59
- | launch | Required | | Name of launch at creation. |
60
- | project | Required | | The name of the project in which the launches will be created. |
61
- | headers | Optional | {} | The object with custom headers for internal http client. |
62
- | debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
63
- | isLaunchMergeRequired | Optional | false | Allows client to merge launches into one at the end of the run via saving their UUIDs to the file system. At the end of the run launches can be merged using `mergeLaunches` method. |
64
- | restClientConfig | Optional | Not set | The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`. |
65
- | 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
- | token | Deprecated | Not set | Use `apiKey` instead. |
55
+ | Option | Necessity | Default | Description |
56
+ |-----------------------|------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
57
+ | apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
58
+ | endpoint | Required | | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'. |
59
+ | launch | Required | | Name of the launch at creation. |
60
+ | project | Required | | The name of the project in which the launches will be created. |
61
+ | headers | Optional | {} | The object with custom headers for internal http client. |
62
+ | debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
63
+ | 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 | The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`. |
65
+ | 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
+ | token | Deprecated | Not set | Use `apiKey` instead. |
68
68
 
69
69
  ## Asynchronous reporting
70
70
 
@@ -130,7 +130,7 @@ The method takes one argument:
130
130
 
131
131
  | Option | Necessity | Default | Description |
132
132
  |-------------|-----------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
133
- | startTime | Optional | rpClient.helpers.now() | (optional) start time launch(unix time). |
133
+ | startTime | Optional | rpClient.helpers.now() | Start time of the launch (unix time). |
134
134
  | name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
135
135
  | mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
136
136
  | description | Optional | '' | Description of the launch (supports markdown syntax). |
@@ -338,6 +338,44 @@ The method takes three arguments:
338
338
  | type | Required | | The file mimeType, example 'image/png' (support types: 'image/*', application/['xml', 'javascript', 'json', 'css', 'php'], other formats will be opened in reportportal in a new browser tab only). |
339
339
  | content | Required | | base64 encoded file content. |
340
340
 
341
+ ### mergeLaunches
342
+
343
+ `mergeLaunches` - merges already completed runs into one (useful when running tests in multiple threads on the same machine).
344
+
345
+ **Note:** Works only if `isLaunchMergeRequired` option is set to `true`.
346
+
347
+ ```javascript
348
+ rpClient.mergeLaunches({
349
+ description: 'Regression tests',
350
+ attributes: [
351
+ {
352
+ key: 'build',
353
+ value: '1.0.0'
354
+ }
355
+ ],
356
+ endTime: rpClient.helpers.now(),
357
+ extendSuitesDescription: false,
358
+ launches: [1, 2, 3],
359
+ mergeType: 'BASIC',
360
+ mode: 'DEFAULT',
361
+ name: 'Launch name',
362
+ })
363
+ ```
364
+ The method takes one argument:
365
+
366
+ * merge options object (optional):
367
+
368
+ | Option | Necessity | Default | Description |
369
+ |-------------------------|-----------|-----------------------------------------|------------------------------------------------------------------------------------------------------------|
370
+ | description | Optional | config.description or 'Merged launch' | Description of the launch (supports markdown syntax). |
371
+ | attributes | Optional | config.attributes or [] | Array of launch attributes (tags). |
372
+ | endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time) |
373
+ | extendSuitesDescription | Optional | true | Whether to extend suites description or not. |
374
+ | launches | Optional | ids of the launches saved to filesystem | The array of the real launch ids, not UUIDs |
375
+ | mergeType | Optional | 'BASIC' | The type of the merge operation. Possible values are 'BASIC' or 'DEEP'. |
376
+ | mode | Optional | config.mode or 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
377
+ | name | Optional | config.launch or 'Test launch name' | Name of the launch after merge. |
378
+
341
379
  # Copyright Notice
342
380
 
343
381
  Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.14-SNAPSHOT
1
+ 5.0.16-SNAPSHOT
@@ -0,0 +1,19 @@
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
+ }
@@ -7,6 +7,7 @@ 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');
10
11
 
11
12
  const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString();
12
13
 
@@ -115,11 +116,11 @@ class RPClient {
115
116
  return RestClient.request('GET', url, {}, { headers: this.headers });
116
117
  }
117
118
 
118
- triggerStatisticsEvent() {
119
+ async triggerStatisticsEvent() {
119
120
  if (process.env.REPORTPORTAL_CLIENT_JS_NO_ANALYTICS) {
120
121
  return;
121
122
  }
122
- this.statistics.trackEvent();
123
+ await this.statistics.trackEvent();
123
124
  }
124
125
 
125
126
  /**
@@ -206,7 +207,7 @@ class RPClient {
206
207
  );
207
208
  });
208
209
  }
209
- this.triggerStatisticsEvent();
210
+ this.triggerStatisticsEvent().catch(console.error);
210
211
  return {
211
212
  tempId,
212
213
  promise: this.map[tempId].promiseStart,
@@ -245,6 +246,7 @@ class RPClient {
245
246
  this.restClient.update(url, finishExecutionData, { headers: this.headers }).then(
246
247
  (response) => {
247
248
  this.logDebug(`Success finish launch with tempId ${launchTempId}`, response);
249
+ console.log(`\nReportPortal Launch Link: ${response.link}`);
248
250
  launchObj.resolveFinish(response);
249
251
  },
250
252
  (error) => {
@@ -581,32 +583,38 @@ class RPClient {
581
583
 
582
584
  itemObj.finishSend = true;
583
585
  this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
584
- Promise.all(
586
+ Promise.allSettled(
585
587
  itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish),
586
- ).then(
587
- () => {
588
+ )
589
+ .then((results) => {
590
+ if (this.debug) {
591
+ results.forEach((result, index) => {
592
+ if (result.status === 'fulfilled') {
593
+ this.logDebug(
594
+ `Successfully finish child with tempId ${itemObj.children[index]}
595
+ of test item with tempId ${itemTempId}`,
596
+ );
597
+ } else {
598
+ this.logDebug(
599
+ `Failed to finish child with tempId ${itemObj.children[index]}
600
+ of test item with tempId ${itemTempId}`,
601
+ );
602
+ }
603
+ });
604
+ }
605
+
588
606
  this.cleanMap(itemObj.children);
589
- this.logDebug(
590
- `All children for test item with tempId ${itemTempId} successfully finished.`,
591
- );
607
+
592
608
  this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
593
609
  this.finishTestItemPromiseStart(
594
610
  itemObj,
595
611
  itemTempId,
596
612
  Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
597
613
  );
598
- },
599
- () => {
600
- this.cleanMap(itemObj.children);
614
+ })
615
+ .catch(() => {
601
616
  this.logDebug(`Error finish children of test item with tempId ${itemTempId}`);
602
- this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
603
- this.finishTestItemPromiseStart(
604
- itemObj,
605
- itemTempId,
606
- Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
607
- );
608
- },
609
- );
617
+ });
610
618
 
611
619
  return {
612
620
  tempId: itemTempId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/client-javascript",
3
- "version": "5.0.13",
3
+ "version": "5.0.15",
4
4
  "description": "ReportPortal client for Node.js",
5
5
  "author": "ReportPortal.io",
6
6
  "scripts": {
@@ -28,20 +28,24 @@ class Statistics {
28
28
  }
29
29
 
30
30
  async trackEvent() {
31
- const requestBody = {
32
- client_id: await getClientId(),
33
- events: [
34
- {
35
- name: this.eventName,
36
- params: this.eventParams,
37
- },
38
- ],
39
- };
31
+ try {
32
+ const requestBody = {
33
+ client_id: await getClientId(),
34
+ events: [
35
+ {
36
+ name: this.eventName,
37
+ params: this.eventParams,
38
+ },
39
+ ],
40
+ };
40
41
 
41
- await axios.post(
42
- `https://www.google-analytics.com/mp/collect?measurement_id=${MEASUREMENT_ID}&api_secret=${API_KEY}`,
43
- requestBody,
44
- );
42
+ await axios.post(
43
+ `https://www.google-analytics.com/mp/collect?measurement_id=${MEASUREMENT_ID}&api_secret=${API_KEY}`,
44
+ requestBody,
45
+ );
46
+ } catch (error) {
47
+ console.error(error.message);
48
+ }
45
49
  }
46
50
  }
47
51