Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@reportportal/client-javascript
Advanced tools
@reportportal/client-javascript is a client library for integrating JavaScript-based test automation frameworks with ReportPortal, a real-time reporting and analysis platform for automated tests. This package allows you to send test results, logs, and other relevant data to ReportPortal, enabling comprehensive test reporting and analysis.
Initialize Client
This feature allows you to initialize the ReportPortal client with necessary configuration details such as token, endpoint, and project name.
const ReportPortalClient = require('@reportportal/client-javascript');
const client = new ReportPortalClient({
token: 'your_token',
endpoint: 'https://your-instance.reportportal.io',
project: 'your_project_name'
});
Start Launch
This feature allows you to start a new launch in ReportPortal, which is a collection of test runs. The response contains a launch ID that you can use for further operations.
client.startLaunch({
name: 'Launch Name',
startTime: new Date().toISOString()
}).then(response => {
const launchId = response.id;
// Use launchId for further operations
});
Log Messages
This feature allows you to send log messages to ReportPortal. You can specify the log level, message, and associated test item.
client.sendLog({
launch: 'launchId',
item: 'testItemId',
level: 'INFO',
message: 'This is a log message',
time: new Date().toISOString()
});
Finish Launch
This feature allows you to finish a launch in ReportPortal, marking the end of a collection of test runs.
client.finishLaunch('launchId', {
endTime: new Date().toISOString()
});
Mochawesome is a custom reporter for the Mocha JavaScript test framework that generates a visually appealing HTML report. Unlike @reportportal/client-javascript, which integrates with ReportPortal for real-time reporting and analysis, Mochawesome focuses on generating static reports from Mocha test results.
Allure JS Commons is a utility library for integrating JavaScript test frameworks with Allure, a flexible and lightweight multi-language test report tool. Similar to @reportportal/client-javascript, it allows for detailed test reporting, but it integrates with Allure instead of ReportPortal.
Jest HTML Reporter is a Jest test framework reporter that generates a simple HTML report. While it provides a way to visualize test results, it lacks the real-time reporting and advanced analysis features of @reportportal/client-javascript.
This Client is to communicate with the Report Portal on node js.
Library is used only for implementors of custom listeners for ReportPortal.
Examples for test framework integrations from the list above described in examples repository.
The latest version is available on npm:
npm install @reportportal/client-javascript
let RPClient = require('@reportportal/client-javascript');
let rpClient = new RPClient({
token: "00000000-0000-0000-0000-000000000000",
endpoint: "http://your-instance.com:8080/api/v1",
launch: "LAUNCH_NAME",
project: "PROJECT_NAME"
});
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);
});
When creating a client instance, you need to specify the following parameters:
Parameter | Description |
---|---|
token | user's token Report Portal from which you want to send requests. It can be found on the profile page of this user. |
endpoint | URL 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'. |
launch | Name of launch at creation. |
project | The name of the project in which the launches will be created. |
headers | (optional) The object with custom headers for internal http client |
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.
The client supports an asynchronous reporting. If you want the client to work asynchronously change v1 to v2 in addresses in endpoint
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 - starts a new launch, return temp id that you want to use for all of the items within this launch.
let 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:
Parameter | Description |
---|---|
startTime | (optional) start time launch(unix time). Default: rpClient.helpers.now() |
name | (optional) launch name. Default: parameter 'launch' specified when creating the client instance |
mode | (optional) "DEFAULT" or "DEBUG". Default: "DEFAULT" |
description | (optional) description of the launch (supports markdown syntax) |
attributes | (optional) array of launch tags |
id | id of the existing launch in which tests data would be sent, without this param new launch instance would be created |
To know the real launch id wait for the method to finish. The real id is used by the client in asynchronous reporting.
let 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):
We use Google Analytics for sending anonymous usage information as library's name/version and the agent's name/version when the launchStart is called. This information might help us to improve reportportal-client. Used by the ReportPortal team only and not for sharing with 3rd parties. You can disable Google Analytics by specify the following parameter disableGA with the value true.
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'
let launchFinishObj = rpClient.finishLaunch(launchObj.tempId, {
endTime: rpClient.helpers.now()
});
The method takes two arguments:
Parameter | Description |
---|---|
endTime | (optional) end time of launch. Default: rpClient.helpers.now() |
status | (optional) status of launch, one of "", "PASSED", "FAILED", "STOPPED", "SKIPPED", "INTERRUPTED", "CANCELLED". |
getPromiseFinishAllItems - returns promise that contains status about all data has been sent to the Report Protal. This method needed when test frameworks don't wait for async methods and stop processed.
// jasmine example. tempLaunchId - id of the client's process
agent.getPromiseFinishAllItems(agent.tempLaunchId).then(()=> done());
Parameter | Description |
---|---|
tempLaunchId | id of the client's process |
updateLaunch - updates 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:
startTestItem - starts a new test item.
// launchObj - object returned by method 'startLaunch'
let suiteObj = rpClient.startTestItem({
description: makeid(),
name: makeid(),
startTime: rpClient.helpers.now(),
type: "SUITE"
}, launchObj.tempId);
let 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:
Parameter | Description |
---|---|
name | item name |
type | 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' |
description | (optional) description of the launch (supports markdown syntax) |
startTime | (optional) start time item(unix time). Default: rpClient.helpers.now() |
attributes | (optional) array of item attributes |
finishTestItem - finish of the item. After calling this method, you can not add items to the item. The request to finish the item will be sent only after all items within it have finished.
// itemObj - object returned by method 'startTestItem'
rpClient.finishTestItem(itemObj.tempId, {
status: "failed"
})
The method takes two arguments:
Parameter | Description |
---|---|
endTime | (optional) end time of launch. Default: rpClient.helpers.now() |
status | (optional) item status, one of "", "PASSED", "FAILED", "STOPPED", "SKIPPED", "INTERRUPTED", "CANCELLED". Default: "PASSED". |
issue | (optional) object issue. IssueType is required, allowable values: "pb***", "ab***", "si***", "ti***", "nd001". Where *** is locator id |
Example issue object:
{
issueType: "string",
comment: "string",
externalSystemIssues: [
{
submitDate: 0,
submitter: "string",
systemId: "string",
ticketId: "string",
url: "string"
}
]
}
sendLog - adds a log to the item
// stepObj - object returned by method 'startTestItem'
rpClient.sendLog(stepObj.tempId, {
level: "INFO",
message: makeid(),
time: rpClient.helpers.now()
})
The method takes three arguments:
Parameter | Description |
---|---|
time | (optional) time of log. Default: rpClient.helpers.now() |
message | (optional) log message. Default: ''. |
status | (optional) log status, one of 'trace', 'debug', 'info', 'warn', 'error', ''. Default "". |
Parameter | Description |
---|---|
name | file name |
type | file mimeType, example "image/png" (support types: 'image/*', application/ ['xml', 'javascript', 'json', 'css', 'php'] , another format will be opened in a new browser tab ), |
content | file |
Licensed under the Apache 2.0 license (see the LICENSE.txt file).
[5.0.1] - 2020-08-14
FAQs
ReportPortal client for Node.js
The npm package @reportportal/client-javascript receives a total of 118,574 weekly downloads. As such, @reportportal/client-javascript popularity was classified as popular.
We found that @reportportal/client-javascript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.