ReportPortal JavaScript Client

2.2.1 · active · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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);
});

view raw JSON →