@reportportal/client-javascript 5.2.0 → 5.3.0

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
@@ -129,13 +129,13 @@ console.log(launchObj.tempId);
129
129
  The method takes one argument:
130
130
  * launch data object:
131
131
 
132
- | Option | Necessity | Default | Description |
133
- |-------------|-----------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
134
- | startTime | Optional | rpClient.helpers.now() | Start time of the launch (unix time). |
135
- | name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
136
- | mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
137
- | description | Optional | '' | Description of the launch (supports markdown syntax). |
138
- | attributes | Optional | [] | Array of launch attributes (tags). |
132
+ | Option | Necessity | Default | Description |
133
+ |-------------|-----------|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
134
+ | startTime | Optional | rpClient.helpers.now() | Start time of the launch (Unix Epoch time, see [time format](#time-format)). |
135
+ | name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
136
+ | mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
137
+ | description | Optional | '' | Description of the launch (supports markdown syntax). |
138
+ | attributes | Optional | [] | Array of launch attributes (tags). |
139
139
  | id | Optional | Not set | `ID` of the existing launch in which tests data would be sent, without this param new launch instance will be created. |
140
140
 
141
141
  To get the real launch `ID` (also known as launch `UUID` from database) wait for the returned promise to finish.
@@ -180,9 +180,9 @@ The method takes two arguments:
180
180
  * launch `tempId` (returned by the method `startLaunch`)
181
181
  * data object:
182
182
 
183
- |Option | Necessity | Default | Description |
184
- |--------- |-----------|---------|---------------------------------------------------------------------------------------------------|
185
- |endTime | Optional | rpClient.helpers.now() | End time of the launch. |
183
+ |Option | Necessity | Default | Description |
184
+ |--------- |-----------|---------|----------------------------------------------------------------------------------------------------|
185
+ |endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
186
186
  |status | Optional | '' | Status of launch, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
187
187
 
188
188
  ### getPromiseFinishAllItems
@@ -265,7 +265,7 @@ The method takes three arguments:
265
265
  |type | Required | | Test item type, one of 'SUITE', 'STORY', 'TEST', 'SCENARIO', 'STEP', 'BEFORE_CLASS', 'BEFORE_GROUPS','BEFORE_METHOD', 'BEFORE_SUITE', 'BEFORE_TEST', 'AFTER_CLASS', 'AFTER_GROUPS', 'AFTER_METHOD', 'AFTER_SUITE', 'AFTER_TEST' |
266
266
  |hasStats | Optional | true | Changes behavior for test item of type 'STEP'. When set to `true`, step is treaten as a test case (entity containig statistics). When false, step becomes a nested step. |
267
267
  |description | Optional | '' | Description of the test item (supports markdown syntax). |
268
- |startTime | Optional | rpClient.helpers.now() | Start time of the test item (unix time). |
268
+ |startTime | Optional | rpClient.helpers.now() | Start time of the test item (Unix Epoch time, see [time format](#time-format)). |
269
269
  |attributes | Optional | [] | Array of the test item attributes. |
270
270
 
271
271
  * launch `tempId` (returned by the method `startLaunch`)
@@ -289,8 +289,8 @@ The method takes two arguments:
289
289
  | Option | Necessity | Default | Description |
290
290
  |---------|-----------|------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
291
291
  | issue | Optional | true | Test item issue object. `issueType` is required, allowable values: 'pb***', 'ab***', 'si***', 'ti***', 'nd001'. Where `***` is locator id |
292
- | status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
293
- | endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time). |
292
+ | status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
293
+ | endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
294
294
 
295
295
  Example issue object:
296
296
  ```
@@ -325,11 +325,11 @@ The method takes three arguments:
325
325
  * test item `tempId` (returned by method `startTestItem`)
326
326
  * data object:
327
327
 
328
- | Option | Necessity | Default | Description |
329
- |---------|-----------|------------------------|----------------------------------------------------------------------|
330
- | message | Optional | '' | The log message. |
328
+ | Option | Necessity | Default | Description |
329
+ |---------|-----------|------------------------|---------------------------------------------------------------------|
330
+ | message | Optional | '' | The log message. |
331
331
  | level | Optional | '' | The log level, one of 'trace', 'debug', 'info', 'warn', 'error', ''. |
332
- | time | Optional | rpClient.helpers.now() | The time of the log. |
332
+ | time | Optional | rpClient.helpers.now() | The time of the log (Unix Epoch time, see [time format](#time-format)). |
333
333
 
334
334
  * file object (optional):
335
335
 
@@ -370,13 +370,23 @@ The method takes one argument:
370
370
  |-------------------------|-----------|-----------------------------------------|------------------------------------------------------------------------------------------------------------|
371
371
  | description | Optional | config.description or 'Merged launch' | Description of the launch (supports markdown syntax). |
372
372
  | attributes | Optional | config.attributes or [] | Array of launch attributes (tags). |
373
- | endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time) |
373
+ | endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
374
374
  | extendSuitesDescription | Optional | true | Whether to extend suites description or not. |
375
375
  | launches | Optional | ids of the launches saved to filesystem | The array of the real launch ids, not UUIDs |
376
376
  | mergeType | Optional | 'BASIC' | The type of the merge operation. Possible values are 'BASIC' or 'DEEP'. |
377
377
  | mode | Optional | config.mode or 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
378
378
  | name | Optional | config.launch or 'Test launch name' | Name of the launch after merge. |
379
379
 
380
+ ## Time format
381
+
382
+ The unix Epoch time ISO string.
383
+
384
+ The [ReportPortal since product version 24.2]() (Service API version 5.12.0) supports the time with microsecond precision in the ISO string format (`2024-09-23T11:10:46.793546Z`).
385
+ Thus, it is recommended to report time in this format to have more accurate logs and test items order on the ReportPortal UI.
386
+ **Note:** Reporting the time in ISO string format with millisecond precision (`2024-09-23T11:10:46.793Z`) or as a number of milliseconds (`1727089846793`) is also acceptable with microseconds automatically added as zeros for backward compatibility.
387
+
388
+ The client use time with microsecond precision in the ISO string format by default since [version 5.3.0]().
389
+
380
390
  # Copyright Notice
381
391
 
382
392
  Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.2.1-SNAPSHOT
1
+ 5.3.1-SNAPSHOT
package/lib/helpers.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const glob = require('glob');
3
3
  const os = require('os');
4
+ const microtime = require('microtime');
4
5
  const RestClient = require('./rest');
5
6
  const pjson = require('../package.json');
6
7
 
@@ -11,92 +12,110 @@ const PJSON_NAME = pjson.name;
11
12
 
12
13
  const getUUIDFromFileName = (filename) => filename.match(/rplaunch-(.*)\.tmp/)[1];
13
14
 
14
- module.exports = {
15
- formatName(name) {
16
- const len = name.length;
17
- // eslint-disable-next-line no-mixed-operators
18
- return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
19
- },
20
-
21
- now() {
22
- return new Date().valueOf();
23
- },
24
-
25
- // TODO: deprecate and remove
26
- getServerResult(url, request, options, method) {
27
- return new RestClient(options).request(method, url, request, options);
28
- },
29
-
30
- readLaunchesFromFile() {
31
- const files = glob.sync('rplaunch-*.tmp');
32
- const ids = files.map(getUUIDFromFileName);
33
-
34
- return ids;
35
- },
36
-
37
- saveLaunchIdToFile(launchId) {
38
- const filename = `rplaunch-${launchId}.tmp`;
39
- fs.open(filename, 'w', (err) => {
40
- if (err) {
41
- throw err;
42
- }
43
- });
44
- },
45
-
46
- getSystemAttribute() {
47
- const osType = os.type();
48
- const osArchitecture = os.arch();
49
- const RAMSize = os.totalmem();
50
- const nodeVersion = process.version;
51
- const systemAttr = [
52
- {
53
- key: 'client',
54
- value: `${PJSON_NAME}|${PJSON_VERSION}`,
55
- system: true,
56
- },
57
- {
58
- key: 'os',
59
- value: `${osType}|${osArchitecture}`,
60
- system: true,
61
- },
62
- {
63
- key: 'RAMSize',
64
- value: RAMSize,
65
- system: true,
66
- },
67
- {
68
- key: 'nodeJS',
69
- value: nodeVersion,
70
- system: true,
71
- },
72
- ];
73
-
74
- return systemAttr;
75
- },
76
-
77
- generateTestCaseId(codeRef, params) {
78
- if (!codeRef) {
79
- return;
15
+ const formatName = (name) => {
16
+ const len = name.length;
17
+ // eslint-disable-next-line no-mixed-operators
18
+ return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
19
+ };
20
+
21
+ const formatMicrosecondsToISOString = (timestampInMicroseconds) => {
22
+ const milliseconds = Math.floor(timestampInMicroseconds / 1000);
23
+ const microseconds = String(timestampInMicroseconds).slice(-3);
24
+ const isoDate = new Date(milliseconds).toISOString();
25
+
26
+ return isoDate.replace('Z', `${microseconds}Z`);
27
+ };
28
+
29
+ const now = () => {
30
+ return formatMicrosecondsToISOString(microtime.now());
31
+ };
32
+
33
+ // TODO: deprecate and remove
34
+ const getServerResult = (url, request, options, method) => {
35
+ return new RestClient(options).request(method, url, request, options);
36
+ };
37
+
38
+ const readLaunchesFromFile = () => {
39
+ const files = glob.sync('rplaunch-*.tmp');
40
+ const ids = files.map(getUUIDFromFileName);
41
+
42
+ return ids;
43
+ };
44
+
45
+ const saveLaunchIdToFile = (launchId) => {
46
+ const filename = `rplaunch-${launchId}.tmp`;
47
+ fs.open(filename, 'w', (err) => {
48
+ if (err) {
49
+ throw err;
80
50
  }
51
+ });
52
+ };
53
+
54
+ const getSystemAttribute = () => {
55
+ const osType = os.type();
56
+ const osArchitecture = os.arch();
57
+ const RAMSize = os.totalmem();
58
+ const nodeVersion = process.version;
59
+ const systemAttr = [
60
+ {
61
+ key: 'client',
62
+ value: `${PJSON_NAME}|${PJSON_VERSION}`,
63
+ system: true,
64
+ },
65
+ {
66
+ key: 'os',
67
+ value: `${osType}|${osArchitecture}`,
68
+ system: true,
69
+ },
70
+ {
71
+ key: 'RAMSize',
72
+ value: RAMSize,
73
+ system: true,
74
+ },
75
+ {
76
+ key: 'nodeJS',
77
+ value: nodeVersion,
78
+ system: true,
79
+ },
80
+ ];
81
+
82
+ return systemAttr;
83
+ };
84
+
85
+ const generateTestCaseId = (codeRef, params) => {
86
+ if (!codeRef) {
87
+ return;
88
+ }
81
89
 
82
- if (!params) {
83
- return codeRef;
90
+ if (!params) {
91
+ return codeRef;
92
+ }
93
+
94
+ const parameters = params.reduce(
95
+ (result, item) => (item.value ? result.concat(item.value) : result),
96
+ [],
97
+ );
98
+
99
+ return `${codeRef}[${parameters}]`;
100
+ };
101
+
102
+ const saveLaunchUuidToFile = (launchUuid) => {
103
+ const filename = `rp-launch-uuid-${launchUuid}.tmp`;
104
+ fs.open(filename, 'w', (err) => {
105
+ if (err) {
106
+ throw err;
84
107
  }
108
+ });
109
+ };
85
110
 
86
- const parameters = params.reduce(
87
- (result, item) => (item.value ? result.concat(item.value) : result),
88
- [],
89
- );
90
-
91
- return `${codeRef}[${parameters}]`;
92
- },
93
-
94
- saveLaunchUuidToFile(launchUuid) {
95
- const filename = `rp-launch-uuid-${launchUuid}.tmp`;
96
- fs.open(filename, 'w', (err) => {
97
- if (err) {
98
- throw err;
99
- }
100
- });
101
- },
111
+ module.exports = {
112
+ formatName,
113
+ formatMicrosecondsToISOString,
114
+ now,
115
+ getServerResult,
116
+ readLaunchesFromFile,
117
+ saveLaunchIdToFile,
118
+ getSystemAttribute,
119
+ generateTestCaseId,
120
+ saveLaunchUuidToFile,
102
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/client-javascript",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "ReportPortal client for Node.js",
5
5
  "author": "ReportPortal.io",
6
6
  "scripts": {
@@ -29,7 +29,8 @@
29
29
  "glob": "^8.1.0",
30
30
  "ini": "^2.0.0",
31
31
  "uniqid": "^5.4.0",
32
- "uuid": "^9.0.1"
32
+ "uuid": "^9.0.1",
33
+ "microtime": "^3.1.1"
33
34
  },
34
35
  "license": "Apache-2.0",
35
36
  "devDependencies": {