Loading repository data…
Loading repository data…
reportportal / repository
Agent to integrate Jest with ReportPortal.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Agent to integrate Jest with ReportPortal.
npm install --save-dev @reportportal/agent-js-jest
1. Create jest.config.js file with reportportal configuration:
module.exports = {
testRunner: 'jest-circus/runner',
testRegex: ['/__tests__/.*.spec.js?$'],
reporters: [
'default',
[
'@reportportal/agent-js-jest',
{
apiKey: 'reportportalApiKey',
endpoint: 'https://your.reportportal.server/api/v2',
project: 'Your reportportal project name',
launch: 'Your launch name',
attributes: [
{
key: 'key',
value: 'value',
},
{
value: 'value',
},
],
description: 'Your launch description',
}
]
],
...
};
In case you use the jest config section of package.json, add the following entry:
{
"jest": {
...
"reporters": [
"default",
["@reportportal/agent-js-jest",
{
"token": "reportportalApiKey",
"endpoint": "https://your.reportportal.server/api/v2",
"project": "Your reportportal project name",
"launch": "Your launch name",
"attributes": [
{
"key": "key",
"value": "value"
},
{
"value": "value"
}
],
"description": "Your launch description"
}]
],
...
}
}
The full list of available options presented below.
The agent supports two authentication methods:
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.
| Option | Necessity | Default | Description |
|---|---|---|---|
| apiKey | Conditional | User'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. | |
| oauth | Conditional | OAuth 2.0 configuration object. When provided, OAuth authentication will be used instead of API key. See OAuth Configuration below. |
The oauth object supports the following properties:
| Property | Necessity | Default | Description |
|---|---|---|---|
| tokenEndpoint | Required | OAuth 2.0 token endpoint URL for password grant flow. | |
| username | Required | Username for OAuth 2.0 password grant. | |
| password | Required | Password for OAuth 2.0 password grant. | |
| clientId | Required | OAuth 2.0 client ID. | |
| clientSecret | Optional | OAuth 2.0 client secret (optional, depending on your OAuth server configuration). | |
| scope | Optional | OAuth 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).
const rpConfig = {
endpoint: 'https://your.reportportal.server/api/v2',
project: 'Your reportportal project name',
launch: 'Your launch 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
}
};
| Option | Necessity | Default | Description |
|---|---|---|---|
| endpoint | Required | URL of your server. For example 'https://server:8080/api/v1'. Use api/v2 for asynchronous reporting. | |
| launch | Required | Name of launch at creation. | |
| project | Required | The name of the project in which the launches will be created. | |
| attributes | Optional | [] | Launch attributes. |
| description | Optional | '' | Launch description. |