Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 5.2.0 #209

Merged
merged 21 commits into from
Sep 17, 2024
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
build
spec/**/*.json
__tests__/**/*.json
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"env": {
"node": true,
"es6": true,
"jasmine": true
"jest": true
},
"rules": {
"valid-jsdoc": ["error", { "requireReturn": false }],
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @AmsterGet @AliakseiLiasnitski
* @AmsterGet
7 changes: 2 additions & 5 deletions .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14, 16, 18, 20]
node: [14, 16, 18, 20, 22]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -50,8 +50,5 @@ jobs:
- name: Run lint
run: npm run lint

- name: Run tests
run: npm test

- name: Check coverage
- name: Run tests and check coverage
run: npm run test:coverage
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- name: Install of node dependencies
run: npm install
- name: Run lint
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Install of node dependencies
run: npm install
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: 'https://npm.pkg.github.com'
scope: '@reportportal'
- name: Publish to GPR
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Read version
id: readVersion
run: |
Expand Down Expand Up @@ -78,9 +78,9 @@ jobs:
versionInfo: ${{ steps.readChangelogEntry.outputs.log_entry }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '12'
- name: Configure git
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create Release
id: createRelease
uses: actions/create-release@v1
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### Changed
- **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.
- The client now creates an instance of the `axios` HTTP client in the constructor.
- The `HOST` HTTP header is added to all requests as it was skipped by the HTTP client.
### Fixed
- Allow using `restClientConfig` in `checkConnect()` method. Thanks to [stevez](https://github.com/stevez).
### Security
- Updated versions of vulnerable packages (braces).

## [5.1.4] - 2024-05-22
### Fixed
Expand All @@ -23,6 +31,8 @@
- **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.
### Security
- Updated versions of vulnerable packages (axios, follow-redirects).
### Deprecated
- Node.js 12 usage. This minor version is the latest that supports Node.js 12.

## [5.0.15] - 2023-11-20
### Added
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ rpClient.checkConnect().then((response) => {

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

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

## Asynchronous reporting

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

## API

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.4
5.1.5-SNAPSHOT
File renamed without changes.
33 changes: 15 additions & 18 deletions spec/config.spec.js → __tests__/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@
expect(error).toBeInstanceOf(ReportPortalRequiredOptionError);
});

it(
'should throw ReportPortalRequiredOptionError in case of option ' + 'not present in options',
() => {
let error;
try {
getRequiredOption({ other: 1 }, 'project');
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error).toBeInstanceOf(ReportPortalRequiredOptionError);
},
);
it('should throw ReportPortalRequiredOptionError in case of option not present in options', () => {
let error;
try {
getRequiredOption({ other: 1 }, 'project');
} catch (e) {
error = e;
}
expect(error).toBeDefined();
expect(error).toBeInstanceOf(ReportPortalRequiredOptionError);
});
});

describe('getApiKey', () => {
Expand All @@ -52,11 +49,11 @@
});

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

getApiKey({ token: '1' });

expect(console.warn).toHaveBeenCalledWith(

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement

Check warning on line 56 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement
`Option 'token' is deprecated. Use 'apiKey' instead.`,
);
});
Expand All @@ -75,42 +72,42 @@

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

expect(console.dir).toHaveBeenCalledWith(

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement

Check warning on line 78 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement
new ReportPortalValidationError('`options` must be an object.'),
);
});

it('should print ReportPortalRequiredOptionError to the console in case of "endpoint" option missed', () => {
spyOn(console, 'dir');
jest.spyOn(console, 'dir').mockImplementation();
getClientConfig({
apiKey: '123',
project: 'prj',
});

expect(console.dir).toHaveBeenCalledWith(new ReportPortalRequiredOptionError('endpoint'));

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement

Check warning on line 90 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement
});

it('should print ReportPortalRequiredOptionError to the console in case of "project" option missed', () => {
spyOn(console, 'dir');
jest.spyOn(console, 'dir').mockImplementation();
getClientConfig({
apiKey: '123',
endpoint: 'https://abc.com',
});

expect(console.dir).toHaveBeenCalledWith(new ReportPortalRequiredOptionError('project'));

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement

Check warning on line 100 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement
});

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

expect(console.dir).toHaveBeenCalledWith(new ReportPortalRequiredOptionError('apiKey'));

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement

Check warning on line 110 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (14)

Unexpected console statement
});
});
});
50 changes: 8 additions & 42 deletions spec/helpers.spec.js → __tests__/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ const os = require('os');
const fs = require('fs');
const glob = require('glob');
const helpers = require('../lib/helpers');
const RestClient = require('../lib/rest');
const pjson = require('../package.json');

describe('Helpers', () => {

describe('formatName', () => {
it('slice last 256 symbols', () => {
expect(helpers.formatName(`a${'b'.repeat(256)}`)).toBe('b'.repeat(256));
Expand All @@ -28,37 +26,9 @@ describe('Helpers', () => {
});
});

describe('getServerResults', () => {
it('calls RestClient#request', () => {
spyOn(RestClient, 'request');

helpers.getServerResult(
'http://localhost:80/api/v1',
{ userId: 1 },
{
headers: {
'X-Custom-Header': 'WOW',
},
},
'POST',
);

expect(RestClient.request).toHaveBeenCalledWith(
'POST',
'http://localhost:80/api/v1',
{ userId: 1 },
{
headers: {
'X-Custom-Header': 'WOW',
},
},
);
});
});

describe('readLaunchesFromFile', () => {
it('should return the right ids', () => {
spyOn(glob, 'sync').and.returnValue(['rplaunch-fileOne.tmp', 'rplaunch-fileTwo.tmp']);
jest.spyOn(glob, 'sync').mockReturnValue(['rplaunch-fileOne.tmp', 'rplaunch-fileTwo.tmp']);

const ids = helpers.readLaunchesFromFile();

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

describe('saveLaunchIdToFile', () => {
it('should call fs.open method with right parameters', () => {
spyOn(fs, 'open');
jest.spyOn(fs, 'open').mockImplementation();

helpers.saveLaunchIdToFile('fileOne');

expect(fs.open).toHaveBeenCalledWith('rplaunch-fileOne.tmp', 'w', jasmine.any(Function));
expect(fs.open).toHaveBeenCalledWith('rplaunch-fileOne.tmp', 'w', expect.any(Function));
});
});

describe('getSystemAttribute', () => {
it('should return correct system attributes', () => {
spyOn(os, 'type').and.returnValue('osType');
spyOn(os, 'arch').and.returnValue('osArchitecture');
spyOn(os, 'totalmem').and.returnValue('1');
jest.spyOn(os, 'type').mockReturnValue('osType');
jest.spyOn(os, 'arch').mockReturnValue('osArchitecture');
jest.spyOn(os, 'totalmem').mockReturnValue('1');
const nodeVersion = process.version;
const expectedAttr = [
{
Expand Down Expand Up @@ -146,15 +116,11 @@ describe('Helpers', () => {

describe('saveLaunchUuidToFile', () => {
it('should call fs.open method with right parameters', () => {
spyOn(fs, 'open');
jest.spyOn(fs, 'open').mockImplementation();

helpers.saveLaunchUuidToFile('fileOne');

expect(fs.open).toHaveBeenCalledWith(
'rp-launch-uuid-fileOne.tmp',
'w',
jasmine.any(Function),
);
expect(fs.open).toHaveBeenCalledWith('rp-launch-uuid-fileOne.tmp', 'w', expect.any(Function));
});
});
});
Loading
Loading