Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
15 changes: 10 additions & 5 deletions .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 EPAM Systems
# Copyright 2025 EPAM Systems
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -34,16 +34,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24

- name: Install dependencies
run: npm install

- name: Build the source code
run: npm run build

- name: Run lint
run: npm run lint

- name: Run tests and check coverage
run: npm run test:coverage
25 changes: 13 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 EPAM Systems
# Copyright 2025 EPAM Systems
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand All @@ -17,16 +17,20 @@ on:
repository_dispatch:
types: [version-released]

permissions:
id-token: write # Required for NPM OIDC
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24
- name: Install dependencies
run: npm install
- name: Build the source code
Expand All @@ -41,27 +45,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Build the source code
run: npm run build
- name: Publish to NPM
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config list
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24
registry-url: 'https://npm.pkg.github.com'
scope: '@reportportal'
- name: Publish to GPR
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 EPAM Systems
# Copyright 2025 EPAM Systems
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- 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@v4
uses: actions/checkout@v5
- name: Setup NodeJS
uses: actions/setup-node@v4
uses: actions/setup-node@v6
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@v4
uses: actions/checkout@v5
- name: Create Release
id: createRelease
uses: actions/create-release@v1
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### Added
- Support for custom log levels in `ReportingApi.log()` and `ReportingApi.launchLog()` methods. You can now pass any string as a log level in addition to the PREDEFINED_LOG_LEVELS enum values (TRACE, DEBUG, INFO, WARN, ERROR, FATAL).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the changelog with step scoped attachments and logs.
Let's also wait for the client release.


## [5.3.2] - 2025-10-29
### Changed
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const rpConfig = {
| skippedIssue | Optional | true | reportportal provides feature to mark skipped tests as not 'To Investigate'. <br/> Option could be equal boolean values: <br/> _true_ - skipped tests considered as issues and will be marked as 'To Investigate' on reportportal. <br/> _false_ - skipped tests will not be marked as 'To Investigate' on application. |
| debug | Optional | false | This flag allows seeing the logs of the client-javascript. Useful for debugging. |
| launchId | Optional | Not set | The _ID_ of an already existing launch. The launch must be in 'IN*PROGRESS' status while the tests are running. Please note that if this \_ID* is provided, the launch will not be finished at the end of the run and must be finished separately. |
| 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 e.g. `proxy`, [`timeout`](https://github.com/reportportal/client-javascript#timeout-30000ms-on-axios-requests). For debugging and displaying logs the `debug: true` option can be used. Use the retry property (number or axios-retry config) to customise [automatic retries](https://github.com/reportportal/client-javascript?tab=readme-ov-file#retry-configuration). <br/> Visit [client-javascript](https://github.com/reportportal/client-javascript) for more details. |
| 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 e.g. `proxy`, [`timeout`](https://github.com/reportportal/client-javascript#timeout-30000ms-on-axios-requests). For debugging and displaying logs the `debug: true` option can be used. Use the retry property (number or axios-retry config) to customise [automatic retries](https://github.com/reportportal/client-javascript?tab=readme-ov-file#retry-configuration). <br/> Visit [client-javascript](https://github.com/reportportal/client-javascript?tab=readme-ov-file#http-client-options) for more details. |
| headers | Optional | {} | The object with custom headers for internal http client. |
| 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`, note that the env variable is only available in the reporter process (it cannot be obtained from tests). |
Expand Down Expand Up @@ -278,7 +278,7 @@ Send logs to report portal for the current test. Should be called inside of corr
`ReportingApi.log(level: LOG_LEVELS, message: string, file?: Attachment, suite?: string);`<br/>
**required**: `level`, `message`<br/>
**optional**: `file`, `suite`<br/>
where `level` can be one of the following: _TRACE_, _DEBUG_, _WARN_, _INFO_, _ERROR_, _FATAL_<br/>
where `level` can be one of the following: _TRACE_, _DEBUG_, _WARN_, _INFO_, _ERROR_, _FATAL_, or a custom log level string<br/>
Example:

```javascript
Expand All @@ -291,6 +291,9 @@ test('should contain logs with attachments', () => {
content: fileContent.toString('base64'),
};
ReportingApi.log('INFO', 'info log with attachment', attachment);

// Custom log level
ReportingApi.log('CUSTOM_LEVEL', 'custom log message', attachment);

expect(true).toBe(true);
});
Expand Down Expand Up @@ -328,7 +331,7 @@ Send logs to report portal for the current launch. Should be called inside of th
`ReportingApi.launchLog(level: LOG_LEVELS, message: string, file?: Attachment);`<br/>
**required**: `level`, `message`<br/>
**optional**: `file`<br/>
where `level` can be one of the following: _TRACE_, _DEBUG_, _WARN_, _INFO_, _ERROR_, _FATAL_<br/>
where `level` can be one of the following: _TRACE_, _DEBUG_, _WARN_, _INFO_, _ERROR_, _FATAL_, or a custom log level string<br/>
Example:

```javascript
Expand All @@ -341,6 +344,9 @@ test('should contain logs with attachments', async () => {
content: fileContent.toString('base64'),
};
ReportingApi.launchLog('INFO', 'info log with attachment', attachment);

// Custom log level
ReportingApi.launchLog('CUSTOM_LAUNCH_LEVEL', 'custom launch log message', attachment);

await expect(true).toBe(true);
});
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.2
5.3.3-SNAPSHOT
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

module.exports = {
roots: ['<rootDir>/src'],
setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
transform: {
'.ts': [
'ts-jest',
Expand Down
14 changes: 9 additions & 5 deletions src/__tests__/reporter/logReporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import helpers from '@reportportal/client-javascript/lib/helpers';
import { RPReporter } from '../../reporter';
import { mockConfig } from '../mocks/configMock';
import { RPClientMock, mockedDate } from '../mocks/RPClientMock';
import { LOG_LEVELS } from '../../constants';
import { PREDEFINED_LOG_LEVELS } from '../../constants';

const playwrightProjectName = 'projectName';
const tempTestItemId = 'tempTestItemId';
Expand All @@ -37,11 +37,15 @@ describe('logs reporting', () => {
};

const log = {
level: LOG_LEVELS.INFO,
level: PREDEFINED_LOG_LEVELS.INFO,
message: 'info log',
file,
};

beforeEach(() => {
reporter.logTime = 0;
});

describe('send log', () => {
test('should send custom log for test item with params', () => {
const spySendLog = jest.spyOn(reporter.client, 'sendLog');
Expand All @@ -51,7 +55,7 @@ describe('logs reporting', () => {
};
const expectedSendLogObj = {
time: mockedDate,
level: LOG_LEVELS.INFO,
level: PREDEFINED_LOG_LEVELS.INFO,
message: 'info log',
};

Expand All @@ -66,7 +70,7 @@ describe('logs reporting', () => {

const expectedSendLogObj = {
time: mockedDate,
level: LOG_LEVELS.INFO,
level: PREDEFINED_LOG_LEVELS.INFO,
message: 'info log',
};

Expand Down Expand Up @@ -156,7 +160,7 @@ describe('logs reporting', () => {
await reporter.onTestEnd(testCase, result);

expect(reporter.sendLog).toHaveBeenCalledWith(tempTestItemId, {
level: LOG_LEVELS.ERROR,
level: PREDEFINED_LOG_LEVELS.ERROR,
message: result.error.stack,
});
});
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/reporter/onStdErr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { RPReporter } from '../../reporter';
import { mockConfig } from '../mocks/configMock';
import { RPClientMock } from '../mocks/RPClientMock';
import { LOG_LEVELS } from '../../constants';
import { PREDEFINED_LOG_LEVELS } from '../../constants';

describe('onStdErr testing', () => {
const reporter = new RPReporter(mockConfig);
Expand All @@ -28,22 +28,22 @@ describe('onStdErr testing', () => {
titlePath: () => ['rootSuite', 'suiteName', 'testTitle'],
};

test('onStdErr call sendTestItemLog with LOG_LEVELS.ERROR', () => {
test('onStdErr call sendTestItemLog with PREDEFINED_LOG_LEVELS.ERROR', () => {
jest.spyOn(reporter, 'sendTestItemLog');
// @ts-ignore
reporter.onStdErr('Some error log', testCase);
expect(reporter.sendTestItemLog).toHaveBeenCalledWith(
{ level: LOG_LEVELS.ERROR, message: 'Some error log' },
{ level: PREDEFINED_LOG_LEVELS.ERROR, message: 'Some error log' },
testCase,
);
});

test('onStdErr call sendTestItemLog with LOG_LEVELS.WARN', () => {
test('onStdErr call sendTestItemLog with PREDEFINED_LOG_LEVELS.WARN', () => {
jest.spyOn(reporter, 'sendTestItemLog');
// @ts-ignore
reporter.onStdErr('Some warn message', testCase);
expect(reporter.sendTestItemLog).toHaveBeenCalledWith(
{ level: LOG_LEVELS.WARN, message: 'Some warn message' },
{ level: PREDEFINED_LOG_LEVELS.WARN, message: 'Some warn message' },
testCase,
);
});
Expand Down
36 changes: 33 additions & 3 deletions src/__tests__/reportingApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import helpers from '@reportportal/client-javascript/lib/helpers';
import { ReportingApi } from '../reportingApi';
import * as utils from '../utils';
import { LOG_LEVELS } from '../constants';
import { PREDEFINED_LOG_LEVELS } from '../constants';
import { mockedDate } from './mocks/RPClientMock';

const reportingApiStatusMethods = [
Expand Down Expand Up @@ -61,7 +61,7 @@
{ method: 'launchFatal', level: 'FATAL' },
];

const mockAnnotations: any[] = [];

Check warning on line 64 in src/__tests__/reportingApi.spec.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

Check warning on line 64 in src/__tests__/reportingApi.spec.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

jest.mock('@playwright/test', () => ({
test: {
Expand Down Expand Up @@ -183,7 +183,22 @@
time: mockedDate,
};
const spySendEventToReporter = jest.spyOn(utils, 'sendEventToReporter');
ReportingApi.log(LOG_LEVELS.INFO, 'message', file, suite);
ReportingApi.log(PREDEFINED_LOG_LEVELS.INFO, 'message', file, suite);

expect(spySendEventToReporter).toHaveBeenCalledWith(event, expectedData, suite);
});

test('ReportingApi.log should accept custom log level as string', () => {
const event = 'rp:addLog';
const customLevel = 'CUSTOM_LEVEL';
const expectedData = {
file,
level: customLevel,
message: 'custom message',
time: mockedDate,
};
const spySendEventToReporter = jest.spyOn(utils, 'sendEventToReporter');
ReportingApi.log(customLevel, 'custom message', file, suite);

expect(spySendEventToReporter).toHaveBeenCalledWith(event, expectedData, suite);
});
Expand Down Expand Up @@ -216,7 +231,22 @@
time: mockedDate,
};
const spySendEventToReporter = jest.spyOn(utils, 'sendEventToReporter');
ReportingApi.launchLog(LOG_LEVELS.INFO, 'message', file);
ReportingApi.launchLog(PREDEFINED_LOG_LEVELS.INFO, 'message', file);

expect(spySendEventToReporter).toHaveBeenCalledWith(event, expectedData);
});

test('ReportingApi.launchLog should accept custom log level as string', () => {
const event = 'rp:addLaunchLog';
const customLevel = 'CUSTOM_LAUNCH_LEVEL';
const expectedData = {
file,
level: customLevel,
message: 'custom launch message',
time: mockedDate,
};
const spySendEventToReporter = jest.spyOn(utils, 'sendEventToReporter');
ReportingApi.launchLog(customLevel, 'custom launch message', file);

expect(spySendEventToReporter).toHaveBeenCalledWith(event, expectedData);
});
Expand Down
40 changes: 40 additions & 0 deletions src/__tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2025 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

jest.mock('@reportportal/client-javascript/lib/helpers', () => ({
now: jest.fn(() => new Date().valueOf()),
formatName: jest.fn((name: string) => {
const MIN = 3;
const MAX = 256;
const len = name.length;
return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
}),
getSystemAttribute: jest.fn(() => []),
generateTestCaseId: jest.fn((codeRef?: string, params?: any[]) => {

Check warning on line 27 in src/__tests__/setup.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

Check warning on line 27 in src/__tests__/setup.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
if (!codeRef) {
return;
}
if (!params) {
return codeRef;
}
const parameters = params.reduce(
(result, item) => (item.value ? result.concat(item.value) : result),
[],
);
return `${codeRef}[${parameters}]`;
}),
}));
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
export { LAUNCH_MODES } from './launchModes';
export { TEST_ITEM_TYPES } from './testItemTypes';
export { STATUSES } from './statuses';
export { LOG_LEVELS } from './logLevels';
export { PREDEFINED_LOG_LEVELS, LOG_LEVELS } from './logLevels';
export {
TestAnnotation,
TestOutcome,
Expand Down
Loading
Loading