Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Changed
- Revert time format back to milliseconds (based on [#217](https://github.com/reportportal/client-javascript/issues/217#issuecomment-2659843471)).
This is also fixing the issue with agent installation on ARM processors.
### Security
- Updated versions of vulnerable packages (axios).

## [5.3.1] - 2025-01-31
### Fixed
Expand Down
47 changes: 18 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ console.log(launchObj.tempId);
The method takes one argument:
* launch data object:

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

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

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

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

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

Example issue object:
```
Expand Down Expand Up @@ -324,11 +324,11 @@ The method takes three arguments:
* test item `tempId` (returned by method `startTestItem`)
* data object:

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

* file object (optional):

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

## Time format

The unix Epoch time ISO string.

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`).
Thus, it is recommended to report time in this format to have more accurate logs and test items order on the ReportPortal UI.

**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.

The client use time with microsecond precision in the ISO string format by default since [version 5.3.0]().

# Copyright Notice

Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.1
5.3.2-SNAPSHOT
34 changes: 2 additions & 32 deletions __tests__/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const os = require('os');
const fs = require('fs');
const glob = require('glob');
const microtime = require('microtime');
const helpers = require('../lib/helpers');
const pjson = require('../package.json');

Expand All @@ -21,38 +20,9 @@ describe('Helpers', () => {
});
});

describe('formatMicrosecondsToISOString', () => {
test('converts microseconds to ISO string with microseconds precision', () => {
const input = 1726842755304456;
const expected = '2024-09-20T14:32:35.304456Z';
const result = helpers.formatMicrosecondsToISOString(input);
expect(result).toBe(expected);
});

test('handles microseconds at the start of the epoch', () => {
const input = 654321;
const expected = '1970-01-01T00:00:00.654321Z';
const result = helpers.formatMicrosecondsToISOString(input);
expect(result).toBe(expected);
});

test('handles rounding down of microseconds correctly', () => {
const input = 1000001;
const expected = '1970-01-01T00:00:01.000001Z';
const result = helpers.formatMicrosecondsToISOString(input);
expect(result).toBe(expected);
});
});

describe('now', () => {
it('should return the current timestamp with microseconds precision in ISO string format', () => {
const spyMicrotime = jest.spyOn(microtime, 'now').mockReturnValue(1726842755304456);
const expectedISOString = '2024-09-20T14:32:35.304456Z';

const result = helpers.now();

expect(spyMicrotime).toHaveBeenCalled();
expect(result).toBe(expectedISOString);
it('returns milliseconds from unix time', () => {
expect(new Date() - helpers.now()).toBeLessThan(100); // less than 100 miliseconds difference
});
});

Expand Down
12 changes: 1 addition & 11 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('fs');
const glob = require('glob');
const os = require('os');
const microtime = require('microtime');
const RestClient = require('./rest');
const pjson = require('../package.json');

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

const formatMicrosecondsToISOString = (timestampInMicroseconds) => {
const milliseconds = Math.floor(timestampInMicroseconds / 1000);
const microseconds = String(timestampInMicroseconds).slice(-3);
const isoDate = new Date(milliseconds).toISOString();

return isoDate.replace('Z', `${microseconds}Z`);
};

const now = () => {
return formatMicrosecondsToISOString(microtime.now());
return new Date().valueOf();
};

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

module.exports = {
formatName,
formatMicrosecondsToISOString,
now,
getServerResult,
readLaunchesFromFile,
Expand Down
Loading
Loading