New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@oxygenhq/rp-client-javascript

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oxygenhq/rp-client-javascript

Special version of ReportPortal client for Oxygen and Node.js 12

latest
Source
npmnpm
Version
5.5.8-beta.5
Version published
Maintainers
2
Created
Source

ReportPortal js client

This Client is to communicate with the ReportPortal on Node.js.

Library is used only for implementors of custom listeners for ReportPortal.

Already implemented listeners:

Examples for test framework integrations from the list above described in examples repository.

Installation

The latest version is available on npm:

npm install @reportportal/client-javascript

Usage example

const RPClient = require('@reportportal/client-javascript');

const rpClient = new RPClient({
    apiKey: 'reportportalApiKey',
    endpoint: 'http://your-instance.com:8080/api/v1',
    launch: 'LAUNCH_NAME',
    project: 'PROJECT_NAME'
});

rpClient.checkConnect().then(() => {
    console.log('You have successfully connected to the server.');
}, (error) => {
    console.log('Error connection to server');
    console.dir(error);
});

Configuration

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

Authentication options

The client supports two authentication methods:

  • API Key Authentication (default)
  • OAuth 2.0 Password Grant (recommended for enhanced security)

Note:
If both authentication methods are provided, OAuth 2.0 will be used.
Either API key or complete OAuth 2.0 configuration is required to connect to ReportPortal.

OptionNecessityDefaultDescription
apiKeyConditionalUser's ReportPortal API key from which you want to send requests. It can be found on the profile page of this user. *Required only if OAuth is not configured.
oauthConditionalOAuth 2.0 configuration object. When provided, OAuth authentication will be used instead of API key. See OAuth Configuration below.

OAuth configuration

The oauth object supports the following properties:

PropertyNecessityDefaultDescription
tokenEndpointRequiredOAuth 2.0 token endpoint URL for password grant flow.
usernameRequiredUsername for OAuth 2.0 password grant.
passwordRequiredPassword for OAuth 2.0 password grant.
clientIdRequiredOAuth 2.0 client ID.
clientSecretOptionalOAuth 2.0 client secret (optional, depending on your OAuth server configuration).
scopeOptionalOAuth 2.0 scope (optional, space-separated list of scopes).

Note: The OAuth interceptor automatically handles token refresh when the token is about to expire (1 minute before expiration).

OAuth 2.0 configuration example
const RPClient = require('@reportportal/client-javascript');

const rpClient = new RPClient({
    endpoint: 'http://your-instance.com:8080/api/v1',
    launch: 'LAUNCH_NAME',
    project: 'PROJECT_NAME',
    oauth: {
        tokenEndpoint: 'https://your-oauth-server.com/oauth/token',
        username: 'your-username',
        password: 'your-password',
        clientId: 'your-client-id',
        clientSecret: 'your-client-secret', // optional
        scope: 'reportportal', // optional
    }
});

rpClient.checkConnect().then(() => {
    console.log('You have successfully connected to the server.');
}, (error) => {
    console.log('Error connection to server');
    console.dir(error);
});

General options

OptionNecessityDefaultDescription
endpointRequiredURL 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'.
launchRequiredName of the launch at creation.
projectRequiredThe name of the project in which the launches will be created.
headersOptional{}The object with custom headers for internal http client.
debugOptionalfalseThis flag allows seeing the logs of the client. Useful for debugging.
isLaunchMergeRequiredOptionalfalseAllows 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.
restClientConfigOptionalNot setCheck the details in the HTTP client config.
launchUuidPrintOptionalfalseWhether to print the current launch UUID.
launchUuidPrintOutputOptional'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.
skippedIsNotIssueOptionalFalseReportPortal provides feature to mark skipped tests as not 'To Investigate'. Option could be equal boolean values: true - skipped tests will not be marked as 'To Investigate' on application. false - skipped tests considered as issues and will be marked as 'To Investigate' on application.

HTTP client options

axios like http client config.

Timeout (30000ms) on axios requests

There is a timeout on axios requests. If for instance the server your making a request to is taking too long to load, then axios timeout will work and you will see the error 'Error: timeout of 30000ms exceeded'.

You can simply change this timeout by adding a timeout property to restClientConfig with your desired numeric value (in ms) or 0 to disable it.

Debug

Use debug: true for debugging.

Agent

Use agent property to provide http(s) agent options. Use this property in case the direct httpAgent/httpsAgent instance property cannot be used due to config serializations.

Retry configuration

The client retries failed HTTP calls up to 6 times with an exponential backoff (starting at 200 ms and capping at 5 s) and resets the axios timeout before each retry. Provide a retry option in restClientConfig to change that behaviour. The value can be either a number (overriding just the retry count) or a full axios-retry configuration object:

const axiosRetry = require('axios-retry').default;

const client = new RPClient({
  // ... other options
  restClientConfig: {
    retry: {
      retries: 5,
      retryDelay: axiosRetry.exponentialDelay,
    },
  },
});

Setting retry: 0 disables automatic retries.

Proxy configuration

The client supports comprehensive proxy configuration for both HTTP and HTTPS requests, including ReportPortal API calls and OAuth token requests. Proxy settings can be configured via restClientConfig or environment variables.

Basic proxy configuration
Via configuration object
const RPClient = require('@reportportal/client-javascript');

const rpClient = new RPClient({
    apiKey: 'your_api_key',
    endpoint: 'http://your-instance.com:8080/api/v1',
    launch: 'LAUNCH_NAME',
    project: 'PROJECT_NAME',
    restClientConfig: {
        proxy: {
            protocol: 'https',  // 'http' or 'https'
            host: '127.0.0.1',
            port: 8080,
            // Optional authentication
            auth: {
                username: 'proxy-user',
                password: 'proxy-password'
            }
        }
    }
});
Via proxy URL string
const rpClient = new RPClient({
    // ... other options
    restClientConfig: {
        proxy: 'https://127.0.0.1:8080'
    }
});
Via environment variables

The client automatically detects and uses proxy environment variables:

export HTTPS_PROXY=https://127.0.0.1:8080
export HTTP_PROXY=http://127.0.0.1:8080
export NO_PROXY=localhost,127.0.0.1,.local
Bypassing proxy for specific domains (noProxy)

Use the noProxy option to exclude specific domains from being proxied. This is useful when some services are accessible directly while others require a proxy.

const rpClient = new RPClient({
    // ... other options
    restClientConfig: {
        proxy: {
            protocol: 'https',
            host: '127.0.0.1',
            port: 8080
        },
        // Bypass proxy for these domains
        noProxy: 'localhost,127.0.0.1,internal.company.com,.local.domain'
    }
});

noProxy format:

  • Exact hostname: example.com - matches example.com and sub.example.com
  • Leading dot: .example.com - matches only subdomains like sub.example.com (not example.com itself)
  • Wildcard: * - bypass proxy for all requests
  • Multiple entries: Comma-separated list

Priority: Configuration noProxy takes precedence over NO_PROXY environment variable.

Proxy with OAuth authentication

When using OAuth authentication, the proxy configuration is automatically applied to both:

  • OAuth token endpoint requests
  • ReportPortal API requests
const rpClient = new RPClient({
    endpoint: 'http://your-instance.com:8080/api/v1',
    project: 'PROJECT_NAME',
    oauth: {
        tokenEndpoint: 'https://login.microsoftonline.com/.../oauth2/v2.0/token',
        username: 'your-username',
        password: 'your-password',
        clientId: 'your-client-id'
    },
    restClientConfig: {
        proxy: {
            protocol: 'https',
            host: '127.0.0.1',
            port: 8080
        },
        // Example: Use proxy for OAuth, bypass for ReportPortal
        noProxy: 'your-instance.com'
    }
});
Advanced proxy scenarios
Disable proxy explicitly
restClientConfig: {
    proxy: false  // Disable proxy even if environment variables are set
}
Debug proxy configuration

Enable debug mode to see detailed proxy decision logs:

restClientConfig: {
    proxy: { /* ... */ },
    noProxy: 'localhost,.local',
    debug: true  // See proxy-related logs
}

Debug output example:

[ProxyHelper] getProxyConfig called:
  URL: https://login.microsoftonline.com/oauth2/v2.0/token
  Hostname: login.microsoftonline.com
  noProxy from config: localhost,.local
  Should bypass proxy: false
[ProxyHelper] Creating proxy agent:
  URL: https://login.microsoftonline.com/oauth2/v2.0/token
  Protocol: https:
  Proxy URL: https://127.0.0.1:8080
Proxy configuration options
OptionTypeDescription
proxyfalse | string | objectProxy configuration. Can be false (disable), URL string, or configuration object (see below)
proxy.protocolstringProxy protocol: 'http' or 'https'
proxy.hoststringProxy host address
proxy.portnumberProxy port number
proxy.authobjectOptional proxy authentication
proxy.auth.usernamestringProxy username
proxy.auth.passwordstringProxy password
noProxystringComma-separated list of domains to bypass proxy
How proxy handling works
  • Per-request proxy decision: Each request (API or OAuth) determines its proxy configuration based on the target URL
  • noProxy checking: URLs matching noProxy patterns bypass the proxy and connect directly
  • Default agents for bypassed URLs: When a URL bypasses proxy, a default HTTP/HTTPS agent is used to prevent automatic proxy detection
  • Environment variable support: HTTP_PROXY, HTTPS_PROXY, and NO_PROXY are automatically detected and used if no explicit configuration is provided
  • Priority: Explicit configuration takes precedence over environment variables

Asynchronous reporting

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

Each method (except checkConnect) returns an object in a specific format:

{
    tempId: '4ds43fs', // generated by the client id for further work with the created item
    promise: Promise // An object indicating the completion of an operation
}

The client works synchronously, so it is not necessary to wait for the end of the previous requests to send following ones.

checkConnect

checkConnect - asynchronous method for verifying the correctness of the client connection

rpClient.checkConnect().then((response) => {
    console.log('You have successfully connected to the server.');
    console.log(`You are using an account: ${response.fullName}`);
}, (error) => {
    console.log('Error connection to server');
    console.dir(error);
});

startLaunch

startLaunch - starts a new launch, return temp id that you want to use for the all items within this launch.

const launchObj = rpClient.startLaunch({
    name: 'Client test',
    startTime: rpClient.helpers.now(),
    description: 'description of the launch',
    attributes: [
        {
            'key': 'yourKey',
            'value': 'yourValue'
        },
        {
            'value': 'yourValue'
        }
    ],
    //this param used only when you need client to send data into the existing launch
    id: 'id'
});
console.log(launchObj.tempId);

The method takes one argument:

  • launch data object:
OptionNecessityDefaultDescription
startTimeOptionalrpClient.helpers.now()Start time of the launch (unix time).
nameOptionalparameter 'launch' specified when creating the client instanceName of the launch.
modeOptional'DEFAULT''DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page.
descriptionOptional''Description of the launch (supports markdown syntax).
attributesOptional[]Array of launch attributes (tags).
idOptionalNot setID of the existing launch in which tests data would be sent, without this param new launch instance will be created.

To get the real launch ID (also known as launch UUID from database) wait for the returned promise to finish.

const launchObj = rpClient.startLaunch();
launchObj.promise.then((response) => {
    console.log(`Launch real id: ${response.id}`);
}, (error) => {
    console.dir(`Error at the start of launch: ${error}`);
})

As system attributes, this method sends the following data (these data are not for public use):

  • client name, version;
  • agent name, version (if given);
  • browser name, version (if given);
  • OS type, architecture;
  • RAMSize;
  • nodeJS version;

ReportPortal is supporting now integrations with more than 15 test frameworks simultaneously. In order to define the most popular agents and plan the team workload accordingly, we are using Google Analytics.

ReportPortal collects only information about agent name, version and version of Node.js. This information is sent to Google Analytics on the launch start. Please help us to make our work effective. If you still want to switch Off Google Analytics, please change env variable. 'REPORTPORTAL_CLIENT_JS_NO_ANALYTICS=true'

finishLaunch

finishLaunch - finish of the launch. After calling this method, you can not add items to the launch. The request to finish the launch will be sent only after all items within it have finished.

// launchObj - object returned by method 'startLaunch'
const launchFinishObj = rpClient.finishLaunch(launchObj.tempId, {
    endTime: rpClient.helpers.now()
});

The method takes two arguments:

  • launch tempId (returned by the method startLaunch)
  • data object:
OptionNecessityDefaultDescription
endTimeOptionalrpClient.helpers.now()End time of the launch.
statusOptional''Status of launch, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'.

getPromiseFinishAllItems

getPromiseFinishAllItems - returns promise that contains status about all data has been sent to the reportportal. This method needed when test frameworks don't wait for async methods until finished.

// jasmine example. tempLaunchId - tempId of the launch started by the current client process
agent.getPromiseFinishAllItems(agent.tempLaunchId).then(() => done());
OptionNecessityDefaultDescription
tempLaunchIdRequiredtempId of the launch started by the current client process

updateLaunch

updateLaunch - updates the launch data. Will send a request to the server only after finishing the launch.

// launchObj - object returned by method 'startLaunch'
rpClient.updateLaunch(
    launchObj.tempId,
  {
        description: 'new launch description',
        attributes: [
            {
                key: 'yourKey',
                value: 'yourValue'
            },
            {
                value: 'yourValue'
            }
        ],
        mode: 'DEBUG'
    }
);

The method takes two arguments:

  • launch tempId (returned by the method 'startLaunch')
  • data object - may contain the following fields: description, attributes, mode. These fields can be looked up in the method startLaunch.

startTestItem

startTestItem - starts a new test item.

// launchObj - object returned by method 'startLaunch'
const suiteObj = rpClient.startTestItem({
        description: makeid(),
        name: makeid(),
        startTime: rpClient.helpers.now(),
        type: 'SUITE'
    }, launchObj.tempId);
const stepObj = rpClient.startTestItem({
        description: makeid(),
        name: makeid(),
        startTime: rpClient.helpers.now(),
        attributes: [

            {
                key: 'yourKey',
                value: 'yourValue'
            },
            {
                value: 'yourValue'
            }
        ],
        type: 'STEP'
    }, launchObj.tempId, suiteObj.tempId);

The method takes three arguments:

  • test item data object:
OptionNecessityDefaultDescription
nameRequiredTest item name
typeRequiredTest item type, one of 'SUITE', 'STORY', 'TEST', 'SCENARIO', 'STEP', 'BEFORE_CLASS', 'BEFORE_GROUPS','BEFORE_METHOD', 'BEFORE_SUITE', 'BEFORE_TEST', 'AFTER_CLASS', 'AFTER_GROUPS', 'AFTER_METHOD', 'AFTER_SUITE', 'AFTER_TEST'
hasStatsOptionaltrueChanges behavior for test item of type 'STEP'. When set to true, step is treaten as a test case (entity containig statistics). When false, step becomes a nested step.
descriptionOptional''Description of the test item (supports markdown syntax).
startTimeOptionalrpClient.helpers.now()Start time of the test item (unix time).
attributesOptional[]Array of the test item attributes.
  • launch tempId (returned by the method startLaunch)
  • parent test item tempId (optional) (returned by method startTestItem)

finishTestItem

finishTestItem - finish of the test item. After calling this method, you can not add items to the test item. The request to finish the test item will be sent only after all test items within it have finished.

// itemObj - object returned by method 'startTestItem'
rpClient.finishTestItem(itemObj.tempId, {
    status: 'failed'
})

The method takes two arguments:

  • test item tempId (returned by the method startTestItem)
  • data object:
OptionNecessityDefaultDescription
issueOptionaltrueTest item issue object. issueType is required, allowable values: 'pb***', 'ab***', 'si***', 'ti***', 'nd001'. Where *** is locator id
statusOptional'PASSED'Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'.
endTimeOptionalrpClient.helpers.now()End time of the launch (unix time).

Example issue object:

{
    issueType: 'string',
    comment: 'string',
    externalSystemIssues: [
        {
            submitDate: 0,
            submitter: 'string',
            systemId: 'string',
            ticketId: 'string',
            url: 'string'
        }
    ]
}

sendLog

sendLog - adds a log to the test item.

// stepObj - object returned by method 'startTestItem'
rpClient.sendLog(stepObj.tempId, {
    level: 'INFO',
    message: 'User clicks login button',
    time: rpClient.helpers.now()
})

The method takes three arguments:

  • test item tempId (returned by method startTestItem)
  • data object:
OptionNecessityDefaultDescription
messageOptional''The log message.
levelOptional''The log level, one of 'trace', 'debug', 'info', 'warn', 'error', ''.
timeOptionalrpClient.helpers.now()The time of the log.
  • file object (optional):
OptionNecessityDefaultDescription
nameRequiredThe name of the file.
typeRequiredThe file mimeType, example 'image/png' (support types: 'image/*', application/['xml', 'javascript', 'json', 'css', 'php'], other formats will be opened in reportportal in a new browser tab only).
contentRequiredbase64 encoded file content.

mergeLaunches

mergeLaunches - merges already completed runs into one (useful when running tests in multiple threads on the same machine).

Note: Works only if isLaunchMergeRequired option is set to true.

rpClient.mergeLaunches({
    description: 'Regression tests',
    attributes: [
      {
        key: 'build',
        value: '1.0.0'
      }
    ],
    endTime: rpClient.helpers.now(),
    extendSuitesDescription: false,
    launches: [1, 2, 3],
    mergeType: 'BASIC',
    mode: 'DEFAULT',
    name: 'Launch name',
})

The method takes one argument:

  • merge options object (optional):
OptionNecessityDefaultDescription
descriptionOptionalconfig.description or 'Merged launch'Description of the launch (supports markdown syntax).
attributesOptionalconfig.attributes or []Array of launch attributes (tags).
endTimeOptionalrpClient.helpers.now()End time of the launch (unix time)
extendSuitesDescriptionOptionaltrueWhether to extend suites description or not.
launchesOptionalids of the launches saved to filesystemThe array of the real launch ids, not UUIDs
mergeTypeOptional'BASIC'The type of the merge operation. Possible values are 'BASIC' or 'DEEP'.
modeOptionalconfig.mode or 'DEFAULT''DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page.
nameOptionalconfig.launch or 'Test launch name'Name of the launch after merge.

Licensed under the Apache 2.0 license (see the LICENSE.txt file).

Keywords

epam

FAQs

Package last updated on 02 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts