Skip to content

Commit 46f703c

Browse files
authored
Merge pull request #227 from reportportal/develop
Release 5.4.0
2 parents 7a48248 + abae198 commit 46f703c

File tree

8 files changed

+71
-153
lines changed

8 files changed

+71
-153
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### Changed
2+
- Revert time format back to milliseconds (based on [#217](https://github.com/reportportal/client-javascript/issues/217#issuecomment-2659843471)).
3+
This is also fixing the issue with agent installation on ARM processors.
4+
### Security
5+
- Updated versions of vulnerable packages (axios).
16

27
## [5.3.1] - 2025-01-31
38
### Fixed

README.md

+18-29
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ console.log(launchObj.tempId);
128128
The method takes one argument:
129129
* launch data object:
130130

131-
| Option | Necessity | Default | Description |
132-
|-------------|-----------|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
133-
| startTime | Optional | rpClient.helpers.now() | Start time of the launch (Unix Epoch time, see [time format](#time-format)). |
134-
| name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
135-
| mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
136-
| description | Optional | '' | Description of the launch (supports markdown syntax). |
137-
| attributes | Optional | [] | Array of launch attributes (tags). |
131+
| Option | Necessity | Default | Description |
132+
|-------------|-----------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
133+
| startTime | Optional | rpClient.helpers.now() | Start time of the launch (unix time). |
134+
| name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
135+
| mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
136+
| description | Optional | '' | Description of the launch (supports markdown syntax). |
137+
| attributes | Optional | [] | Array of launch attributes (tags). |
138138
| 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. |
139139

140140
To get the real launch `ID` (also known as launch `UUID` from database) wait for the returned promise to finish.
@@ -179,9 +179,9 @@ The method takes two arguments:
179179
* launch `tempId` (returned by the method `startLaunch`)
180180
* data object:
181181

182-
|Option | Necessity | Default | Description |
183-
|--------- |-----------|---------|----------------------------------------------------------------------------------------------------|
184-
|endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
182+
|Option | Necessity | Default | Description |
183+
|--------- |-----------|---------|---------------------------------------------------------------------------------------------------|
184+
|endTime | Optional | rpClient.helpers.now() | End time of the launch. |
185185
|status | Optional | '' | Status of launch, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
186186

187187
### getPromiseFinishAllItems
@@ -264,7 +264,7 @@ The method takes three arguments:
264264
|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' |
265265
|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. |
266266
|description | Optional | '' | Description of the test item (supports markdown syntax). |
267-
|startTime | Optional | rpClient.helpers.now() | Start time of the test item (Unix Epoch time, see [time format](#time-format)). |
267+
|startTime | Optional | rpClient.helpers.now() | Start time of the test item (unix time). |
268268
|attributes | Optional | [] | Array of the test item attributes. |
269269

270270
* launch `tempId` (returned by the method `startLaunch`)
@@ -288,8 +288,8 @@ The method takes two arguments:
288288
| Option | Necessity | Default | Description |
289289
|---------|-----------|------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
290290
| issue | Optional | true | Test item issue object. `issueType` is required, allowable values: 'pb***', 'ab***', 'si***', 'ti***', 'nd001'. Where `***` is locator id |
291-
| status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
292-
| endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
291+
| status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
292+
| endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time). |
293293

294294
Example issue object:
295295
```
@@ -324,11 +324,11 @@ The method takes three arguments:
324324
* test item `tempId` (returned by method `startTestItem`)
325325
* data object:
326326

327-
| Option | Necessity | Default | Description |
328-
|---------|-----------|------------------------|---------------------------------------------------------------------|
329-
| message | Optional | '' | The log message. |
327+
| Option | Necessity | Default | Description |
328+
|---------|-----------|------------------------|----------------------------------------------------------------------|
329+
| message | Optional | '' | The log message. |
330330
| level | Optional | '' | The log level, one of 'trace', 'debug', 'info', 'warn', 'error', ''. |
331-
| time | Optional | rpClient.helpers.now() | The time of the log (Unix Epoch time, see [time format](#time-format)). |
331+
| time | Optional | rpClient.helpers.now() | The time of the log. |
332332

333333
* file object (optional):
334334

@@ -369,24 +369,13 @@ The method takes one argument:
369369
|-------------------------|-----------|-----------------------------------------|------------------------------------------------------------------------------------------------------------|
370370
| description | Optional | config.description or 'Merged launch' | Description of the launch (supports markdown syntax). |
371371
| attributes | Optional | config.attributes or [] | Array of launch attributes (tags). |
372-
| endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
372+
| endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time) |
373373
| extendSuitesDescription | Optional | true | Whether to extend suites description or not. |
374374
| launches | Optional | ids of the launches saved to filesystem | The array of the real launch ids, not UUIDs |
375375
| mergeType | Optional | 'BASIC' | The type of the merge operation. Possible values are 'BASIC' or 'DEEP'. |
376376
| mode | Optional | config.mode or 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
377377
| name | Optional | config.launch or 'Test launch name' | Name of the launch after merge. |
378378

379-
## Time format
380-
381-
The unix Epoch time ISO string.
382-
383-
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`).
384-
Thus, it is recommended to report time in this format to have more accurate logs and test items order on the ReportPortal UI.
385-
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 on ReportPortal's API service 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-
390379
# Copyright Notice
391380

392381
Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.3.1
1+
5.3.2-SNAPSHOT

__tests__/helpers.spec.js

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const os = require('os');
22
const fs = require('fs');
33
const glob = require('glob');
4-
const microtime = require('microtime');
54
const helpers = require('../lib/helpers');
65
const pjson = require('../package.json');
76

@@ -21,38 +20,9 @@ describe('Helpers', () => {
2120
});
2221
});
2322

24-
describe('formatMicrosecondsToISOString', () => {
25-
test('converts microseconds to ISO string with microseconds precision', () => {
26-
const input = 1726842755304456;
27-
const expected = '2024-09-20T14:32:35.304456Z';
28-
const result = helpers.formatMicrosecondsToISOString(input);
29-
expect(result).toBe(expected);
30-
});
31-
32-
test('handles microseconds at the start of the epoch', () => {
33-
const input = 654321;
34-
const expected = '1970-01-01T00:00:00.654321Z';
35-
const result = helpers.formatMicrosecondsToISOString(input);
36-
expect(result).toBe(expected);
37-
});
38-
39-
test('handles rounding down of microseconds correctly', () => {
40-
const input = 1000001;
41-
const expected = '1970-01-01T00:00:01.000001Z';
42-
const result = helpers.formatMicrosecondsToISOString(input);
43-
expect(result).toBe(expected);
44-
});
45-
});
46-
4723
describe('now', () => {
48-
it('should return the current timestamp with microseconds precision in ISO string format', () => {
49-
const spyMicrotime = jest.spyOn(microtime, 'now').mockReturnValue(1726842755304456);
50-
const expectedISOString = '2024-09-20T14:32:35.304456Z';
51-
52-
const result = helpers.now();
53-
54-
expect(spyMicrotime).toHaveBeenCalled();
55-
expect(result).toBe(expectedISOString);
24+
it('returns milliseconds from unix time', () => {
25+
expect(new Date() - helpers.now()).toBeLessThan(100); // less than 100 miliseconds difference
5626
});
5727
});
5828

lib/helpers.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const fs = require('fs');
22
const glob = require('glob');
33
const os = require('os');
4-
const microtime = require('microtime');
54
const RestClient = require('./rest');
65
const pjson = require('../package.json');
76

@@ -18,16 +17,8 @@ const formatName = (name) => {
1817
return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
1918
};
2019

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-
2920
const now = () => {
30-
return formatMicrosecondsToISOString(microtime.now());
21+
return new Date().valueOf();
3122
};
3223

3324
// TODO: deprecate and remove
@@ -110,7 +101,6 @@ const saveLaunchUuidToFile = (launchUuid) => {
110101

111102
module.exports = {
112103
formatName,
113-
formatMicrosecondsToISOString,
114104
now,
115105
getServerResult,
116106
readLaunchesFromFile,

0 commit comments

Comments
 (0)