{"id":15803,"library":"reportportal-js-client","title":"ReportPortal JavaScript Client","description":"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.","status":"active","version":"2.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/BorisOsipov/reportportal-js-client","tags":["javascript"],"install":[{"cmd":"npm install reportportal-js-client","lang":"bash","label":"npm"},{"cmd":"yarn add reportportal-js-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add reportportal-js-client","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primary CommonJS import pattern as shown in official documentation and examples.","symbol":"RPClient","correct":"const RPClient = require('reportportal-js-client');"},{"note":"For ES Modules, the library provides a default export. Named imports will not work for the main client class.","wrong":"import { RPClient } from 'reportportal-js-client';","symbol":"RPClient","correct":"import RPClient from 'reportportal-js-client';"},{"note":"Access to utility functions like `now()` is through the client instance's `helpers` property.","symbol":"rpClient.helpers.now","correct":"const startTime = rpClient.helpers.now();"}],"quickstart":{"code":"import RPClient from 'reportportal-js-client';\n\nconst rpClient = new RPClient({\n    token: process.env.REPORTPORTAL_TOKEN ?? 'YOUR_REPORTPORTAL_TOKEN',\n    endpoint: process.env.REPORTPORTAL_ENDPOINT ?? 'http://your-instance.com:8080/api/v1',\n    launch: process.env.REPORTPORTAL_LAUNCH_NAME ?? 'MyTestLaunch',\n    project: process.env.REPORTPORTAL_PROJECT_NAME ?? 'MyProject'\n});\n\nrpClient.checkConnect().then((response) => {\n    console.log('Successfully connected to ReportPortal server.');\n    console.log(`Using account: ${response.fullName}`);\n\n    const launchObj = rpClient.startLaunch({\n        name: 'Client Test Launch',\n        startTime: rpClient.helpers.now(),\n        description: 'Example launch from quickstart',\n        attributes: [{ key: 'env', value: 'dev' }]\n    });\n\n    console.log(`Launch started with tempId: ${launchObj.tempId}`);\n\n    // You would typically add test items here and finish the launch later.\n    // For this quickstart, we'll just finish it immediately for demonstration.\n    rpClient.finishLaunch(launchObj.tempId, { endTime: rpClient.helpers.now() });\n    console.log(`Launch ${launchObj.tempId} finished.`);\n\n}, (error) => {\n    console.error('Error connecting to ReportPortal server:');\n    console.error(error);\n});","lang":"typescript","description":"Demonstrates how to initialize the ReportPortal client, check connectivity, and start and finish a basic launch."},"warnings":[{"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.","message":"Version 2.0.0 and subsequent versions dropped support for Report Portal 4. The client now exclusively supports Report Portal 5 and newer versions.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always format your endpoint as `http://your-instance.com:8080/api/v1` (or `v2`).","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set `endpoint: \"http://your-instance.com:8080/api/v2\"` in the client configuration to utilize asynchronous reporting features.","message":"For 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Obtain the user token from your ReportPortal profile settings and ensure it is correctly provided in the client configuration.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"While 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"Incorrect `endpoint` URL, invalid `token`, or network connectivity issues to the ReportPortal server.","error":"Error connection to server"},{"fix":"Use the correct ES Module import syntax: `import RPClient from 'reportportal-js-client';`.","cause":"Attempting to use `import { RPClient } from 'reportportal-js-client';` in an ES Module context. The library exports `RPClient` as a default export.","error":"TypeError: RPClient is not a constructor"},{"fix":"Ensure all required parameters (`token`, `endpoint`, `launch`, `project`) are provided as properties in the configuration object when creating a new `RPClient` instance.","cause":"Missing one or more required configuration parameters (`token`, `endpoint`, `launch`, `project`) when instantiating `RPClient`.","error":"Error: Not all parameters are specified."}],"ecosystem":"npm"}