Gathering detailed insights and metrics for @reportportal/agent-js-cypress
Gathering detailed insights and metrics for @reportportal/agent-js-cypress
Gathering detailed insights and metrics for @reportportal/agent-js-cypress
Gathering detailed insights and metrics for @reportportal/agent-js-cypress
@reportportal/client-javascript
ReportPortal client for Node.js
@reportportal/agent-js-playwright
Agent to integrate Playwright with ReportPortal.
reportportalcypressjunitagent
Report Portal JUnit Cypress Agent
@reportportal/agent-js-jest
A Jest reporter that uploads test results to ReportPortal
npm install @reportportal/agent-js-cypress
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
39 Stars
346 Commits
39 Forks
29 Watching
3 Branches
33 Contributors
Updated on 23 Sept 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
12.1%
3,810
Compared to previous day
Last week
-1.3%
21,447
Compared to previous week
Last month
-16.7%
93,166
Compared to previous month
Last year
135.3%
1,109,899
Compared to previous year
9
Agent to integrate Cypress with ReportPortal.
1$ npm install --save-dev @reportportal/agent-js-cypress
There is a configuration guide for Cypress version 10 and above.
Add the following options to cypress.config.js.
1 2const { defineConfig } = require('cypress'); 3const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin'); 4 5module.exports = defineConfig({ 6 reporter: '@reportportal/agent-js-cypress', 7 reporterOptions: { 8 apiKey: '<API_KEY>', 9 endpoint: 'https://your.reportportal.server/api/v1', 10 project: 'Your reportportal project name', 11 launch: 'Your launch name', 12 description: 'Your launch description', 13 attributes: [ 14 { 15 key: 'attributeKey', 16 value: 'attributeValue', 17 }, 18 { 19 value: 'anotherAttributeValue', 20 }, 21 ], 22 }, 23 e2e: { 24 setupNodeEvents(on, config) { 25 return registerReportPortalPlugin(on, config); 26 }, 27 }, 28});
To see more options refer Options.
Add the following to your custom commands file (cypress/support/commands.js):
1 2require('@reportportal/agent-js-cypress/lib/commands/reportPortalCommands');
See examples of usage here.
There is a configuration guide for Cypress version 9 and below.
Add the following options to cypress.json
1 2{ 3 "reporter": "@reportportal/agent-js-cypress", 4 "reporterOptions": { 5 "apiKey": "<API_KEY>", 6 "endpoint": "https://your.reportportal.server/api/v1", 7 "project": "Your reportportal project name", 8 "launch": "Your launch name", 9 "description": "Your launch description", 10 "attributes": [ 11 { 12 "key": "attributeKey", 13 "value": "attributeValue" 14 }, 15 { 16 "value": "anotherAttributeValue" 17 } 18 ] 19 } 20} 21
To see more options refer Options.
1const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin'); 2 3module.exports = (on, config) => registerReportPortalPlugin(on, config);
Add the following to your custom commands file (cypress/support/commands.js):
1require('@reportportal/agent-js-cypress/lib/commands/reportPortalCommands');
The full list of available options presented below.
Option | Necessity | Default | Description |
---|---|---|---|
apiKey | Required | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. | |
endpoint | Required | URL of your server. For example 'https://server:8080/api/v1'. | |
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. |
rerun | Optional | false | Enable rerun |
rerunOf | Optional | Not set | UUID of launch you want to rerun. If not specified, reportportal will update the latest launch with the same name |
mode | Optional | 'DEFAULT' | Results will be submitted to Launches page 'DEBUG' - Results will be submitted to Debug page. |
skippedIssue | Optional | true | reportportal provides feature to mark skipped tests as not 'To Investigate'. Option could be equal boolean values: true - skipped tests considered as issues and will be marked as 'To Investigate' on reportportal. false - skipped tests will not be marked as 'To Investigate' on application. |
debug | Optional | false | This flag allows seeing the logs of the client-javascript. Useful for debugging. |
launchId | Optional | Not set | The ID of an already existing launch. The launch must be in 'IN_PROGRESS' status while the tests are running. Please note that if this ID is provided, the launch will not be finished at the end of the run and must be finished separately. |
launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if launchUuidPrint set to true . |
restClientConfig | Optional | Not set | axios like http client config. May contain agent property for configure http(s) client, and other client options eg. timeout . For debugging and displaying logs you can set debug: true . |
uploadVideo | Optional | false | Whether to upload the Cypress video. Uploads videos for failed specs only. To upload videos for specs with other statuses, set also the uploadVideoForNonFailedSpec to true . |
uploadVideoForNonFailedSpec | Optional | false | Whether to upload the Cypress video for a non-failed specs. Works only if uploadVideo set to true . |
waitForVideoTimeout | Optional | 10000 | Value in ms . Since Cypress video processing may take extra time after the spec is complete, there is a timeout to wait for the video file readiness. Works only if uploadVideo set to true . |
waitForVideoInterval | Optional | 500 | Value in ms . Interval to check if the video file is ready. The interval is used until waitForVideoTimeout is reached. Works only if uploadVideo set to true . |
videoCompression | Optional | false | Whether to compress the Cypress video by the agent before uploading it to the ReportPortal. Settings the same as for Cypress video compression. The quality setting for the video compression, in Constant Rate Factor (CRF). The value can be false or 0 to disable compression or a CRF between 1 and 51 , where a lower value results in better quality (at the expense of a higher file size). Setting this option to true will result in a default CRF of 32. Works only if uploadVideo set to true . |
autoMerge | Optional | false | Enable automatic report test items of all run spec into one launch. You should install plugin or setup additional settings in reporterOptions. See Automatically merge launch. |
reportHooks | Optional | false | Determines report before and after hooks or not. |
isLaunchMergeRequired | Optional | false | Allows to merge Cypress run's into one launch at the end of the run. Needs additional setup. See Manual merge launches. |
parallel | Optional | false | Indicates to the reporter that spec files will be executed in parallel on different machines. Parameter could be equal boolean values. See Parallel execution. |
token | Deprecated | Not set | Use apiKey instead. |
If you run Cypress tests programmatically or use cypress.config.js
, you can simply overwrite them:
1const updatedConfig = { 2 ...config, 3 reporterOptions: { 4 ...config.reporterOptions, 5 apiKey: process.env.RP_API_KEY, 6 }, 7};
For security reasons, you can also set token as a part of Environment Variables, instead of sharing it in the config file:
Option | ENV variable | Note |
---|---|---|
apiKey | RP_API_KEY | |
token | RP_TOKEN | deprecated Use RP_API_KEY instead. |
ReportPortal provides the following custom commands for reporting logs into the current test.
cy.log(log)
. Reports message as an info log of the current test.You can use the following methods to report logs and attachments with different log levels:
file should be an object:
1{ 2 name: "filename", 3 type: "image/png", // media type 4 content: data, // file content represented as 64base string 5}
Note: The cy.debug
RP command has been changed to cy.logDebug
due to the command with the same name in Cypress 9.*.
addTestAttributes (attributes). Add attributes(tags) to the current test. Should be called inside of corresponding test.
attributes is array of pairs of key and value:
1[{ 2 key: "attributeKey1", 3 value: "attributeValue2", 4}]
Key is optional field.
To integrate with Sauce Labs just add attributes:
1[{ 2 "key": "SLID", 3 "value": "# of the job in Sauce Labs" 4}, { 5 "key": "SLDC", 6 "value": "EU (EU or US)" 7}]
setTestDescription (description). Set text description to the current test. Should be called inside of corresponding test.
setTestCaseId (id, suite). Set test case id to the current test or suite. Should be called inside of corresponding test/suite.
id is a string test case Id.
suite (optional) is the title of the suite to which the specified test case id belongs. Should be provided just in case of reporting test case id for specified suite instead of current test.
ReportPortal provides the following custom commands for setting status to the current suite/spec.
You can use the shorthand forms of the cy.setStatus method:
ReportPortal also provides the corresponding methods for setting status into the launch:
To use custom filename in cy.screenshot function you should setup ReportRortal custom commands. Default usage of Cypress screenshot function is supported without additional setup.
By default Cypress create a separate run for each test file. This section describe how to report test items of different specs into the single launch. This feature needs information about Cypress configuration. To provide it to the reporter you need to install reportPortal plugin (see how to in this section).
Enable auto-merge in reporterOptions as shown below:
1 2{ 3 ... 4 "reporterOptions": { 5 ... 6 "autoMerge": true 7 } 8}
Please note, that autoMerge
feature is unstable in some cases (f.e. when using cypress-grep
or CLI arguments to specify the test amount that should be executed) and may lead to unfinished launches in ReportPortal.
If this is a case, try Manual merge launches instead.
There is a possibility to merge all launches into a single launch at the end of the run. We advise using autoMerge option to merge results in one launch, but you can use this alternative option in case of you need to perform some additional actions before merge.
Edit cypress.config.js (or cypress.json for versions <=9) file. Set isLaunchMergeRequired
option to true as shown below:
1 2{ 3 ... 4 reporterOptions: { 5 ... 6 isLaunchMergeRequired: true 7 } 8} 9
Update the Cypress configuration file with the code presented below (referring the issue https://github.com/reportportal/agent-js-cypress/issues/135#issue-1461470158).
1const delay = async (ms: number) => new Promise((res) => setTimeout(res, ms)); 2 3const reportportalOptions = { 4 //... 5 isLaunchMergeRequired: true, 6 //... 7}; 8 9export default defineConfig({ 10 //... 11 reporter: '@reportportal/agent-js-cypress', 12 reporterOptions: reportportalOptions, 13 e2e: { 14 //... 15 setupNodeEvents(on, config) { 16 // keep Cypress running until the ReportPortal reporter is finished. this is a 17 // very critical step, as otherwise results might not be completely pushed into 18 // ReportPortal, resulting in unfinsihed launches and failing merges 19 on('after:run', async () => { 20 console.log('Wait for reportportal agent to finish...'); 21 while (glob.sync('rplaunchinprogress*.tmp').length > 0) { 22 await delay(2000); 23 } 24 console.log('reportportal agent finished'); 25 if (reportportalOptions.isLaunchMergeRequired) { 26 try { 27 console.log('Merging launches...'); 28 await mergeLaunches(reportportalOptions); 29 console.log('Launches successfully merged!'); 30 deleteLaunchFiles(); 31 } catch (mergeError) { 32 console.error(mergeError); 33 } 34 } 35 }); 36 registerReportPortalPlugin(on, config); 37 return config; 38 }, 39 //... 40 }, 41});
deleteLaunchFiles
example:
1const fs = require("fs"); 2const glob = require("glob"); 3 4function deleteLaunchFiles() { 5 const getLaunchTempFiles = () => { 6 return glob.sync("rplaunch*.tmp"); 7 }; 8 const deleteTempFile = (filename) => { 9 fs.unlinkSync(filename); 10 }; 11 const files = getLaunchTempFiles(); 12 files.forEach(deleteTempFile); 13}
Cypress can run recorded tests in parallel across multiple machines since version 3.1.0 (Cypress docs).
By default Cypress create a separate run for each test file. To merge all runs into one launch in Report Portal you need to provide autoMerge option together with parallel
flag.
Since Cypress does not provide the ci_build_id to the reporter, you need to provide it manually using the CI_BUILD_ID
environment variable (see Cypress docs for details).
Enable parallel in reporterOptions as shown below:
1 2{ 3 ... 4 reporterOptions: { 5 ... 6 parallel: true 7 } 8} 9
Here's an example of setting up parallel Cypress execution on several machines using GitHub Actions:
1 2name: CI-pipeline 3 4on: 5 pull_request: 6 7jobs: 8 test: 9 runs-on: ubuntu-latest 10 container: cypress/browsers:node12.18.3-chrome87-ff82 11 strategy: 12 fail-fast: false 13 matrix: 14 containers: [1, 2, 3] 15 env: 16 CI_BUILD_ID: ${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }} 17 steps: 18 - name: Checkout 19 uses: actions/checkout@v2 20 21 - name: 'UI Tests - Chrome' 22 uses: cypress-io/github-action@v2 23 with: 24 config-file: cypress.json 25 group: 'UI Tests - Chrome' 26 spec: cypress/integration/* 27 record: true 28 parallel: true 29 env: 30 CYPRESS_RECORD_KEY: ${{ secrets.RECORD_KEY }} 31 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 ACTIONS_RUNNER_DEBUG: true 33
Note: The example provided for Cypress version <= 9. For Cypress version >= 10 usage of cypress-io/github-action
may be changed.
Specify the options in the cypress.config.js:
1const { defineConfig } = require('cypress'); 2const createBundler = require('@bahmutov/cypress-esbuild-preprocessor'); 3const preprocessor = require('@badeball/cypress-cucumber-preprocessor'); 4const createEsbuildPlugin = require('@badeball/cypress-cucumber-preprocessor/esbuild').default; 5const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin'); 6 7module.exports = defineConfig({ 8 reporter: '@reportportal/agent-js-cypress', 9 reporterOptions: { 10 endpoint: 'http://your-instance.com:8080/api/v1', 11 apiKey: 'reportportalApiKey', 12 launch: 'LAUNCH_NAME', 13 project: 'PROJECT_NAME', 14 description: 'LAUNCH_DESCRIPTION', 15 }, 16 e2e: { 17 async setupNodeEvents(on, config) { 18 await preprocessor.addCucumberPreprocessorPlugin(on, config); 19 on( 20 'file:preprocessor', 21 createBundler({ 22 plugins: [createEsbuildPlugin(config)], 23 }), 24 ); 25 registerReportPortalPlugin(on, config); 26 27 return config; 28 }, 29 specPattern: 'cypress/e2e/**/*.feature', 30 supportFile: 'cypress/support/e2e.js', 31 }, 32});
At the moment it is not possible to subscribe to start and end of scenario steps events. To solve the problem with displaying steps in the ReportPortal, the agent provides special commands: cucumberStepStart
, cucumberStepEnd
.
To work correctly, these commands must be called in the BeforeStep
/AfterStep
hooks.
1import { BeforeStep, AfterStep } from '@badeball/cypress-cucumber-preprocessor'; 2 3BeforeStep((step) => { 4 cy.cucumberStepStart(step); 5}); 6 7AfterStep((step) => { 8 cy.cucumberStepEnd(step); 9});
You can avoid duplicating this logic in each step definitions. Instead, add it to the cypress/support/step_definitions.js
file and include the path to this file in the stepDefinitions array (if necessary) within cucumber-preprocessor config. These hooks will be used for all step definitions.
Licensed under the Apache License v2.0
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
30 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
Found 2/17 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More