Registry / testing / reportportal-js-client

reportportal-js-client

JSON →
library2.2.1jsnpmunverified

reportportal-js-client is a dedicated Node.js client library for integrating test automation results with the ReportPortal platform. It enables the creation of custom listeners and reporters to programmatically interact with a ReportPortal instance, facilitating the reporting of test launches, suites, and individual test cases. The current stable version is 2.2.1, with major version 2.x focusing exclusively on compatibility with Report Portal 5 and later, having dropped support for Report Portal 4 in version 2.0.0. This client is a fork of the official `client-javascript` and is specifically tailored for Node.js environments, providing methods to start and finish launches, test items, and logs. It emphasizes an asynchronous reporting model, allowing for efficient data transmission without blocking the main execution thread, and offers both synchronous and asynchronous modes for endpoint interaction. Its key differentiator is its robust API for deep integration within Node.js test frameworks for comprehensive test result visualization and analysis within ReportPortal.

npm install reportportal-js-client
INSTALL
IMPORT
SIG · REPORTPORTAL-JS-CL
R
reportportal-js-client
testingjavascriptv2.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RPClient
const RPClient = require('reportportal-js-client');
Primary CommonJS import pattern as shown in official documentation and examples.
RPClient
import RPClient from 'reportportal-js-client';
import { RPClient } from 'reportportal-js-client';
For ES Modules, the library provides a default export. Named imports will not work for the main client class.
rpClient.helpers.now
const startTime = rpClient.helpers.now();
Access to utility functions like `now()` is through the client instance's `helpers` property.

Demonstrates how to initialize the ReportPortal client, check connectivity, and start and finish a basic launch.

import RPClient from 'reportportal-js-client'; const rpClient = new RPClient({ token: process.env.REPORTPORTAL_TOKEN ?? 'YOUR_REPORTPORTAL_TOKEN', endpoint: process.env.REPORTPORTAL_ENDPOINT ?? 'http://your-instance.com:8080/api/v1', launch: process.env.REPORTPORTAL_LAUNCH_NAME ?? 'MyTestLaunch', project: process.env.REPORTPORTAL_PROJECT_NAME ?? 'MyProject' }); rpClient.checkConnect().then((response) => { console.log('Successfully connected to ReportPortal server.'); console.log(`Using account: ${response.fullName}`); const launchObj = rpClient.startLaunch({ name: 'Client Test Launch', startTime: rpClient.helpers.now(), description: 'Example launch from quickstart', attributes: [{ key: 'env', value: 'dev' }] }); console.log(`Launch started with tempId: ${launchObj.tempId}`); // You would typically add test items here and finish the launch later. // For this quickstart, we'll just finish it immediately for demonstration. rpClient.finishLaunch(launchObj.tempId, { endTime: rpClient.helpers.now() }); console.log(`Launch ${launchObj.tempId} finished.`); }, (error) => { console.error('Error connecting to ReportPortal server:'); console.error(error); });
Debug
Known issues
breakingVersion 2.0.0 and subsequent versions dropped support for Report Portal 4. The client now exclusively supports Report Portal 5 and newer versions.
fix
Ensure your Report Portal server instance is version 5 or higher. If not, either downgrade the client to a 1.x version or upgrade your Report Portal server.
affects: >=2.0.0
gotchaThe `endpoint` configuration parameter must specifically point to the ReportPortal API base URL, typically ending with `/api/v1` (or `/api/v2` for asynchronous reporting). Providing the UI URL (e.g., `http://server:8080/ui`) will lead to connection errors.
fix
Always format your endpoint as `http://your-instance.com:8080/api/v1` (or `v2`).
affects: >=1.0.0
gotchaFor asynchronous reporting, the endpoint URL must be modified to use `/api/v2` instead of `/api/v1`. This is a specific behavior to enable a different reporting mode.
fix
Set `endpoint: "http://your-instance.com:8080/api/v2"` in the client configuration to utilize asynchronous reporting features.
affects: >=1.0.0
gotchaThe `token` parameter is mandatory for authentication and must be a valid user token obtained from the user's profile page within the ReportPortal UI. Incorrect or missing tokens will result in authentication failures.
fix
Obtain the user token from your ReportPortal profile settings and ensure it is correctly provided in the client configuration.
affects: >=1.0.0
gotchaWhile the client API calls (e.g., `startLaunch`, `startTestItem`) are synchronous in the sense that they return immediately, the actual network requests are asynchronous and return Promises. It's crucial to handle these promises for operations like `checkConnect` or for ensuring data is sent before application exit.
fix
Always `await` or chain `.then()` and `.catch()` calls on methods that return a Promise (like `checkConnect`) to properly handle their completion or errors. For other methods, collect the `promise` property from the returned object if you need to await their completion.
affects: >=1.0.0
Errors
Common errors & fixes
Error connection to server
Incorrect `endpoint` URL, invalid `token`, or network connectivity issues to the ReportPortal server.
fix
Verify the `endpoint` URL format (e.g., `/api/v1`), confirm the `token` is correct, and ensure the ReportPortal server is running and accessible from the client's environment.
TypeError: RPClient is not a constructor
Attempting to use `import { RPClient } from 'reportportal-js-client';` in an ES Module context. The library exports `RPClient` as a default export.
fix
Use the correct ES Module import syntax: `import RPClient from 'reportportal-js-client';`.
Error: Not all parameters are specified.
Missing one or more required configuration parameters (`token`, `endpoint`, `launch`, `project`) when instantiating `RPClient`.
fix
Ensure all required parameters (`token`, `endpoint`, `launch`, `project`) are provided as properties in the configuration object when creating a new `RPClient` instance.
Upgrade
Version history
2.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources