Skip to content

Commit d511fe1

Browse files
authored
Merge pull request #209 from reportportal/develop
Release 5.2.0
2 parents 0db9e55 + 4070b07 commit d511fe1

27 files changed

+2633
-1179
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
22
build
3-
spec/**/*.json
3+
__tests__/**/*.json

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"env": {
1818
"node": true,
1919
"es6": true,
20-
"jasmine": true
20+
"jest": true
2121
},
2222
"rules": {
2323
"valid-jsdoc": ["error", { "requireReturn": false }],

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @AmsterGet @AliakseiLiasnitski
1+
* @AmsterGet

.github/workflows/CI-pipeline.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
strategy:
3333
matrix:
34-
node: [12, 14, 16, 18, 20]
34+
node: [14, 16, 18, 20, 22]
3535
steps:
3636
- name: Checkout repository
3737
uses: actions/checkout@v4
@@ -50,8 +50,5 @@ jobs:
5050
- name: Run lint
5151
run: npm run lint
5252

53-
- name: Run tests
54-
run: npm test
55-
56-
- name: Check coverage
53+
- name: Run tests and check coverage
5754
run: npm run test:coverage

.github/workflows/publish.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set up Node.js
2727
uses: actions/setup-node@v4
2828
with:
29-
node-version: 18
29+
node-version: 20
3030
- name: Install of node dependencies
3131
run: npm install
3232
- name: Run lint
@@ -45,7 +45,7 @@ jobs:
4545
- name: Set up Node.js
4646
uses: actions/setup-node@v4
4747
with:
48-
node-version: 18
48+
node-version: 20
4949
registry-url: 'https://registry.npmjs.org'
5050
- name: Install of node dependencies
5151
run: npm install
@@ -59,7 +59,7 @@ jobs:
5959
- name: Set up Node.js
6060
uses: actions/setup-node@v4
6161
with:
62-
node-version: 18
62+
node-version: 20
6363
registry-url: 'https://npm.pkg.github.com'
6464
scope: '@reportportal'
6565
- name: Publish to GPR

.github/workflows/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }}
3434
steps:
3535
- name: Checkout repository
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737
- name: Read version
3838
id: readVersion
3939
run: |
@@ -78,9 +78,9 @@ jobs:
7878
versionInfo: ${{ steps.readChangelogEntry.outputs.log_entry }}
7979
steps:
8080
- name: Checkout repository
81-
uses: actions/checkout@v3
81+
uses: actions/checkout@v4
8282
- name: Setup NodeJS
83-
uses: actions/setup-node@v3
83+
uses: actions/setup-node@v4
8484
with:
8585
node-version: '12'
8686
- name: Configure git
@@ -139,7 +139,7 @@ jobs:
139139
runs-on: ubuntu-latest
140140
steps:
141141
- name: Checkout repository
142-
uses: actions/checkout@v3
142+
uses: actions/checkout@v4
143143
- name: Create Release
144144
id: createRelease
145145
uses: actions/create-release@v1

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
### Changed
2+
- **Breaking change** Drop support of Node.js 12. The version [5.1.4](https://github.com/reportportal/client-javascript/releases/tag/v5.1.4) is the latest that supports it.
3+
- The client now creates an instance of the `axios` HTTP client in the constructor.
4+
- The `HOST` HTTP header is added to all requests as it was skipped by the HTTP client.
5+
### Fixed
6+
- Allow using `restClientConfig` in `checkConnect()` method. Thanks to [stevez](https://github.com/stevez).
7+
### Security
8+
- Updated versions of vulnerable packages (braces).
19

210
## [5.1.4] - 2024-05-22
311
### Fixed
@@ -23,6 +31,8 @@
2331
- **Breaking change** Drop support of Node.js 10. The version [5.0.15](https://github.com/reportportal/client-javascript/releases/tag/v5.0.15) is the latest that supports it.
2432
### Security
2533
- Updated versions of vulnerable packages (axios, follow-redirects).
34+
### Deprecated
35+
- Node.js 12 usage. This minor version is the latest that supports Node.js 12.
2636

2737
## [5.0.15] - 2023-11-20
2838
### Added

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ rpClient.checkConnect().then((response) => {
5353

5454
When creating a client instance, you need to specify the following options:
5555

56-
| Option | Necessity | Default | Description |
57-
|-----------------------|------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
58-
| apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
59-
| 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'. |
60-
| launch | Required | | Name of the launch at creation. |
61-
| project | Required | | The name of the project in which the launches will be created. |
62-
| headers | Optional | {} | The object with custom headers for internal http client. |
63-
| debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
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`. |
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`. |
66-
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
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`. |
68-
| token | Deprecated | Not set | Use `apiKey` instead. |
56+
| Option | Necessity | Default | Description |
57+
|-----------------------|------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
58+
| apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
59+
| 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'. |
60+
| launch | Required | | Name of the launch at creation. |
61+
| project | Required | | The name of the project in which the launches will be created. |
62+
| headers | Optional | {} | The object with custom headers for internal http client. |
63+
| debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
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`. |
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`. |
66+
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
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`. |
68+
| token | Deprecated | Not set | Use `apiKey` instead. |
6969

7070
## Asynchronous reporting
7171

72-
The client supports an asynchronous reporting.
73-
If you want the client to work asynchronously change `v1` to `v2` in addresses in endpoint.
72+
The client supports an asynchronous reporting (via the ReportPortal asynchronous API).
73+
If you want the client to report through the asynchronous API, change `v1` to `v2` in the `endpoint` address.
7474

7575
## API
7676

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.4
1+
5.1.5-SNAPSHOT
File renamed without changes.

spec/config.spec.js renamed to __tests__/config.spec.js

+15-18
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@ describe('Config commons test suite', () => {
2323
expect(error).toBeInstanceOf(ReportPortalRequiredOptionError);
2424
});
2525

26-
it(
27-
'should throw ReportPortalRequiredOptionError in case of option ' + 'not present in options',
28-
() => {
29-
let error;
30-
try {
31-
getRequiredOption({ other: 1 }, 'project');
32-
} catch (e) {
33-
error = e;
34-
}
35-
expect(error).toBeDefined();
36-
expect(error).toBeInstanceOf(ReportPortalRequiredOptionError);
37-
},
38-
);
26+
it('should throw ReportPortalRequiredOptionError in case of option not present in options', () => {
27+
let error;
28+
try {
29+
getRequiredOption({ other: 1 }, 'project');
30+
} catch (e) {
31+
error = e;
32+
}
33+
expect(error).toBeDefined();
34+
expect(error).toBeInstanceOf(ReportPortalRequiredOptionError);
35+
});
3936
});
4037

4138
describe('getApiKey', () => {
@@ -52,7 +49,7 @@ describe('Config commons test suite', () => {
5249
});
5350

5451
it('should print warning to console if deprecated token option used', () => {
55-
spyOn(console, 'warn');
52+
jest.spyOn(console, 'warn').mockImplementation();
5653

5754
getApiKey({ token: '1' });
5855

@@ -75,7 +72,7 @@ describe('Config commons test suite', () => {
7572

7673
describe('getClientConfig', () => {
7774
it('should print ReportPortalValidationError error to the console in case of options is not an object type', () => {
78-
spyOn(console, 'dir');
75+
jest.spyOn(console, 'dir').mockImplementation();
7976
getClientConfig('options');
8077

8178
expect(console.dir).toHaveBeenCalledWith(
@@ -84,7 +81,7 @@ describe('Config commons test suite', () => {
8481
});
8582

8683
it('should print ReportPortalRequiredOptionError to the console in case of "endpoint" option missed', () => {
87-
spyOn(console, 'dir');
84+
jest.spyOn(console, 'dir').mockImplementation();
8885
getClientConfig({
8986
apiKey: '123',
9087
project: 'prj',
@@ -94,7 +91,7 @@ describe('Config commons test suite', () => {
9491
});
9592

9693
it('should print ReportPortalRequiredOptionError to the console in case of "project" option missed', () => {
97-
spyOn(console, 'dir');
94+
jest.spyOn(console, 'dir').mockImplementation();
9895
getClientConfig({
9996
apiKey: '123',
10097
endpoint: 'https://abc.com',
@@ -104,7 +101,7 @@ describe('Config commons test suite', () => {
104101
});
105102

106103
it('should print ReportPortalRequiredOptionError to the console in case of "apiKey" option missed', () => {
107-
spyOn(console, 'dir');
104+
jest.spyOn(console, 'dir').mockImplementation();
108105
getClientConfig({
109106
project: 'prj',
110107
endpoint: 'https://abc.com',

spec/helpers.spec.js renamed to __tests__/helpers.spec.js

+8-42
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ const os = require('os');
22
const fs = require('fs');
33
const glob = require('glob');
44
const helpers = require('../lib/helpers');
5-
const RestClient = require('../lib/rest');
65
const pjson = require('../package.json');
76

87
describe('Helpers', () => {
9-
108
describe('formatName', () => {
119
it('slice last 256 symbols', () => {
1210
expect(helpers.formatName(`a${'b'.repeat(256)}`)).toBe('b'.repeat(256));
@@ -28,37 +26,9 @@ describe('Helpers', () => {
2826
});
2927
});
3028

31-
describe('getServerResults', () => {
32-
it('calls RestClient#request', () => {
33-
spyOn(RestClient, 'request');
34-
35-
helpers.getServerResult(
36-
'http://localhost:80/api/v1',
37-
{ userId: 1 },
38-
{
39-
headers: {
40-
'X-Custom-Header': 'WOW',
41-
},
42-
},
43-
'POST',
44-
);
45-
46-
expect(RestClient.request).toHaveBeenCalledWith(
47-
'POST',
48-
'http://localhost:80/api/v1',
49-
{ userId: 1 },
50-
{
51-
headers: {
52-
'X-Custom-Header': 'WOW',
53-
},
54-
},
55-
);
56-
});
57-
});
58-
5929
describe('readLaunchesFromFile', () => {
6030
it('should return the right ids', () => {
61-
spyOn(glob, 'sync').and.returnValue(['rplaunch-fileOne.tmp', 'rplaunch-fileTwo.tmp']);
31+
jest.spyOn(glob, 'sync').mockReturnValue(['rplaunch-fileOne.tmp', 'rplaunch-fileTwo.tmp']);
6232

6333
const ids = helpers.readLaunchesFromFile();
6434

@@ -68,19 +38,19 @@ describe('Helpers', () => {
6838

6939
describe('saveLaunchIdToFile', () => {
7040
it('should call fs.open method with right parameters', () => {
71-
spyOn(fs, 'open');
41+
jest.spyOn(fs, 'open').mockImplementation();
7242

7343
helpers.saveLaunchIdToFile('fileOne');
7444

75-
expect(fs.open).toHaveBeenCalledWith('rplaunch-fileOne.tmp', 'w', jasmine.any(Function));
45+
expect(fs.open).toHaveBeenCalledWith('rplaunch-fileOne.tmp', 'w', expect.any(Function));
7646
});
7747
});
7848

7949
describe('getSystemAttribute', () => {
8050
it('should return correct system attributes', () => {
81-
spyOn(os, 'type').and.returnValue('osType');
82-
spyOn(os, 'arch').and.returnValue('osArchitecture');
83-
spyOn(os, 'totalmem').and.returnValue('1');
51+
jest.spyOn(os, 'type').mockReturnValue('osType');
52+
jest.spyOn(os, 'arch').mockReturnValue('osArchitecture');
53+
jest.spyOn(os, 'totalmem').mockReturnValue('1');
8454
const nodeVersion = process.version;
8555
const expectedAttr = [
8656
{
@@ -146,15 +116,11 @@ describe('Helpers', () => {
146116

147117
describe('saveLaunchUuidToFile', () => {
148118
it('should call fs.open method with right parameters', () => {
149-
spyOn(fs, 'open');
119+
jest.spyOn(fs, 'open').mockImplementation();
150120

151121
helpers.saveLaunchUuidToFile('fileOne');
152122

153-
expect(fs.open).toHaveBeenCalledWith(
154-
'rp-launch-uuid-fileOne.tmp',
155-
'w',
156-
jasmine.any(Function),
157-
);
123+
expect(fs.open).toHaveBeenCalledWith('rp-launch-uuid-fileOne.tmp', 'w', expect.any(Function));
158124
});
159125
});
160126
});

0 commit comments

Comments
 (0)