{"_id":"@an1988/agent-js-cypress","name":"@an1988/agent-js-cypress","dist-tags":{"latest":"5.0.4"},"versions":{"5.0.4":{"name":"@an1988/agent-js-cypress","version":"5.0.4","description":"This agent helps Cypress to communicate with Report Portal","main":"index.js","scripts":{"lint":"eslint . --quiet","format":"npm run lint -- --fix","test":"jest --detectOpenHandles --config ./jest.config.js","test:coverage":"jest --coverage"},"repository":{"type":"git","url":"git+https://github.com/reportportal/agent-js-cypress.git"},"dependencies":{"@reportportal/client-javascript":"^5.0.6","glob":"7.1.3","minimatch":"^3.0.4","mocha":"^8.3.2","node-ipc":"9.1.1"},"directories":{"lib":"./lib"},"license":"Apache-2.0","devDependencies":{"cypress":"^9.3.1","eslint":"6.5.1","eslint-config-airbnb-base":"14.0.0","eslint-config-prettier":"6.9.0","eslint-plugin-cypress":"2.8.1","eslint-plugin-import":"2.20.0","eslint-plugin-jest":"^23.8.1","eslint-plugin-prettier":"3.1.2","jest":"^25.3.0","mock-fs":"^4.11.0","prettier":"1.19.1"},"keywords":["ReportPortal","rp","Cypress","reporting","reporter","epam"],"bugs":{"url":"https://github.com/reportportal/agent-js-cypress/issues"},"homepage":"https://github.com/reportportal/agent-js-cypress#readme","_id":"@an1988/agent-js-cypress@5.0.4","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-O1itdcyKDdJZ/cEuhNSnCor1bd6PNkmWU/4XhGcGOv3bRTr5LYsC6FI5vAxgyLnXaFlO3Eczi+06l9IidoaIBw==","shasum":"41d37760b904c6ebc64494fab2a7abdeae7009d3","tarball":"https://registry.npmjs.org/@an1988/agent-js-cypress/-/agent-js-cypress-5.0.4.tgz","fileCount":17,"unpackedSize":74959,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHePNo+rNLpUs8ucvARggjH9BIHR75R6f5Cbe4fSdFRfAiBtpiV5vnMmaY9Q7Er1t6BeNWTxNEZ7ieS8Fa0G5pRZEw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiqyIyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmopjA/+MF0hj8ynnbVv2GpcVQPjrAlUClpWBFMisTqolfo6mdrv+ssz\r\nonXyMcyQx1vKHauTS+0DkbFybT8jBl57Rmq687Xwr5CXYzu0pV5p9sJnUimJ\r\nZNpgnaJPrQ8IlFjylugW5nVfWBfMxNuT+U9sk1I089JyOIWoUf9XoGd5yIi0\r\nEmrvDvxPUaCet/NghsVzJw1jAWrX1j2TtdWZduBAvCJ3vEmxdFeVKd6He+Kx\r\nrNFoL8f3QBySDqJbtvq78l8OpCFvKZSYNpDAatPnXW6nbjlI9KP/NRruqUq6\r\nlRccNq8nxOfgPZHcJPgtm4kHwDJjDU7sje7pULRUGEtSccKjfx42yOPzgy0W\r\no+Ytx5CU5rPrKN/zpXyAEwBSEul17pyNwm9SmnWciunBVfxbIzaU4dojO7cz\r\nhyTbu5jJD+ih+6bbJUwcBjn2j983hMxMsvYyzU8xfLbH16QVP2MXn4dmWNqH\r\nqvbHq6oqYDiGJGkmnnepQsH3RIzwrJX5VzWYkTj1T48ctvmXW/YX0lMQ8g5x\r\nOzZsdACaFhPPxCJLRydVdD1hYGcj6du4h2Rgm8kZtww4HpdRq8V99KbRtZwx\r\nKMkG0NvPG+MWiTMLUr44pQDufBhJDfpWUUjziqbxPXCL5DrFazJki/61hLSF\r\nKpI1taOdbz8LtJ7AbB9dxkysF/4H806o060=\r\n=cXDE\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"an1988","email":"muzyka.andriy@gmail.com"},"maintainers":[{"name":"an1988","email":"muzyka.andriy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/agent-js-cypress_5.0.4_1655382578117_0.4137204580241096"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-16T12:29:38.075Z","5.0.4":"2022-06-16T12:29:38.349Z","modified":"2022-06-16T12:29:38.495Z"},"maintainers":[{"name":"an1988","email":"muzyka.andriy@gmail.com"}],"description":"This agent helps Cypress to communicate with Report Portal","homepage":"https://github.com/reportportal/agent-js-cypress#readme","keywords":["ReportPortal","rp","Cypress","reporting","reporter","epam"],"repository":{"type":"git","url":"git+https://github.com/reportportal/agent-js-cypress.git"},"bugs":{"url":"https://github.com/reportportal/agent-js-cypress/issues"},"license":"Apache-2.0","readme":"# @reportportal/agent-js-cypress\n\nagent-js-cypress is a runtime reporter for the [Report Portal](https://github.com/reportportal/reportportal) which provides information about collection run.\n\n## Install\n\n```console\n$ npm install @reportportal/agent-js-cypress\n```\n\n## Usage\n\n#### Cypress.json\n\nAdd the following options to cypress.json\n\n```json\n\n{\n  \"reporter\": \"@reportportal/agent-js-cypress\",\n  \"reporterOptions\": {\n    \"endpoint\": \"http://your-instance.com:8080/api/v1\",\n    \"token\": \"00000000-0000-0000-0000-000000000000\",\n    \"launch\": \"LAUNCH_NAME\",\n    \"project\": \"PROJECT_NAME\",\n    \"description\": \"LAUNCH_DESCRIPTION\"\n  }\n}\n\n```\n\n#### Register ReportPortal plugin (cypress/plugins/index.js):\n\n```javascript\n\nconst registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin');\n\nmodule.exports = (on) => registerReportPortalPlugin(on);\n\n```\n\n#### Setup [ReportPortal custom commands](#reportportal-custom-commands)\n\nAdd the following to your custom commands file (cypress/support/commands.js):\n\n```javascript\n\nrequire('@reportportal/agent-js-cypress/lib/commands/reportPortalCommands');\n\n```\n\nSee examples of usage [here](https://github.com/reportportal/examples-js/tree/master/example-cypress).\n\n## Options\n\nRuns support following options:\n\n| Parameter             | Description                                                                                                       |\n| --------------------- | ----------------------------------------------------------------------------------------------------------------- |\n| token                 | User's Report Portal token from which you want to send requests. It can be found on the profile page of this user.|\n| endpoint              | URL of your server. For example 'https://server:8080/api/v1'.                                                     |\n| launch                | Name of launch at creation.                                                                                       |\n| project               | The name of the project in which the launches will be created.                                                    |\n| rerun                 | Enable [rerun](https://github.com/reportportal/documentation/blob/master/src/md/src/DevGuides/rerun.md)           |\n| rerunOf               | UUID of launch you want to rerun. If not specified, report portal will update the latest launch with the same name|\n| mode                  | *Default: \"default\".* Results will be submitting to Launches tab<br> *\"debug\"* - Results will be submitting to Debug tab. |\n| debug                 | This flag allows seeing the logs of the client-javascript. Useful for debugging. Parameter could be equal boolean values. |\n| autoMerge             | Enable automatical report test items of all runned spec into one launch. You should install plugin or setup additional settings in reporterOptions. See [Automatically merge launch](#automatically-merge-launches). |\n| reportHooks           | Determines report before and after hooks or not.                                                                  |\n| skippedIssue          | ReportPortal provides feature to mark skipped tests as not 'To Investigate' items on WS side.<br> Parameter could be equal boolean values:<br> *TRUE* - skipped tests considered as issues and will be marked as 'To Investigate' on Report Portal (default value).<br> *FALSE* - skipped tests will not be marked as 'To Investigate' on application.|\n| isLaunchMergeRequired | Allows to merge Cypress run's into one launch in the end of the run. Needs additional setup. See [Manual merge launches](#manual-merge-launches).  |\n| parallel              | Indicates to the reporter that spec files will be executed in parallel. Parameter could be equal boolean values. See [Parallel execution](#parallel-execution) |\n| restClientConfig      | Optional property.<br/> The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`.<br/> Visit [client-javascript](https://github.com/reportportal/client-javascript) for more details. |\n\n### Overwrite options from config file\n\n**If you run Cypress tests programmatically, you can simply overwrite them:**\n\n```javascript\nconst updatedConfig = {\n  ...config,\n  reporterOptions: {\n    ...config.reporterOptions,\n    token: process.env.RP_TOKEN,\n  },\n};\n\n```\n\n**Overwrite by env variables:**\n\n| Parameter          | Env variable |\n| ------------------ | ---------- |\n| token              | RP_TOKEN |\n\n\n## ReportPortal custom commands\n\n### Logging\n\nReportPortal provides the following custom commands for reporting logs into the current test.\n\n* cy.log(*message*). Overrides standard Cypress `cy.log(log)`. Reports *message* as an info log of the current test.<br/>\n\nYou can use the following methods to report logs and attachments with different log levels:\n* cy.trace (*message* , *file*). Reports *message* and optional *file* as a log of the current test with trace log level.\n* cy.logDebug (*message* , *file*). Reports *message* and optional *file* as a log of the current test with debug log level.\n* cy.info (*message* , *file*). Reports *message* and optional *file* as log of the current test with info log level.\n* cy.warn (*message* , *file*). Reports *message* and optional *file* as a log of the current test with warning log level.\n* cy.error (*message* , *file*). Reports *message* and optional *file* as a log of the current test with error log level.\n* cy.fatal (*message* , *file*). Reports *message* and optional *file* as a log of the current test with fatal log level.\n* cy.launchTrace (*message* , *file*). Reports *message* and optional *file* as a log of the launch with trace log level.\n* cy.launchDebug (*message* , *file*). Reports *message* and optional *file* as a log of the launch with debug log level.\n* cy.launchInfo (*message* , *file*). Reports *message* and optional *file* as log of the launch with info log level.\n* cy.launchWarn (*message* , *file*). Reports *message* and optional *file* as a log of the launch with warning log level.\n* cy.launchError (*message* , *file*). Reports *message* and optional *file* as a log of the launch with error log level.\n* cy.launchFatal (*message* , *file*). Reports *message* and optional *file* as a log of the launch with fatal log level.\n\n*file* should be an object: <br/>\n```javascript\n{\n  name: \"filename\",\n  type: \"image/png\",  // media type\n  content: data,  // file content represented as 64base string\n}\n```\n\n**Note:** The `cy.debug` RP command has been changed to `cy.logDebug` due to the command with the same name in Cypress 9.*.\n\n### Report attributes for tests\n\n**addTestAttributes (*attributes*)**. Add attributes(tags) to the current test. Should be called inside of corresponding test.<br/> \n*attributes* is array of pairs of key and value:\n```javascript\n[{\n  key: \"attributeKey1\",\n  value: \"attributeValue2\",\n}]\n```\n*Key* is optional field.\n\n\n### Integration with Sauce Labs\n\nTo integrate with Sauce Labs just add attributes: \n\n```javascript\n[{\n \"key\": \"SLID\",\n \"value\": \"# of the job in Sauce Labs\"\n}, {\n \"key\": \"SLDC\",\n \"value\": \"EU (EU or US)\"\n}]\n```\n\n### Report description for tests\n\n**setTestDescription (*description*)**. Set text description to the current test. Should be called inside of corresponding test.\n\n### Report test case Id for tests and suites\n\n**setTestCaseId (*id*, *suite*)**. Set test case id to the current test or suite. Should be called inside of corresponding test/suite.<br/> \n*id* is a string test case Id.<br/>\n*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.\n\n### Finish launch/test item with status\n\nReportPortal provides the following custom commands for setting status to the current suite/spec.\n\n* cy.setStatus(*status*, *suite*). Assign *status* to the current test or suite. Should be called inside of corresponding test/suite.<br/>\n*status* should be equal to one of the following values: *passed*, *failed*, *stopped*, *skipped*, *interrupted*, *cancelled*, *info*, *warn*.<br/>\n*suite (optional)* is the title of the suite to which you wish to set the status (all suite descriptions must be unique). Should be provided just in case of assign status for specified suite instead of current test. <br/>\n\nYou can use the shorthand forms of the cy.setStatus method:\n\n* cy.setStatusPassed(*suite*). Assign *passed* status to the current test or suite.\n* cy.setStatusFailed(*suite*). Assign *failed* status to the current test or suite.\n* cy.setStatusSkipped(*suite*). Assign *skipped* status to the current test or suite.\n* cy.setStatusStopped(*suite*). Assign *stopped* status to the current test or suite.\n* cy.setStatusInterrupted(*suite*). Assign *interrupted* status to the current test or suite.\n* cy.setStatusCancelled(*suite*). Assign *cancelled* status to the current test or suite.\n* cy.setStatusInfo(*suite*). Assign *info* status to the current test or suite.\n* cy.setStatusWarn(*suite*). Assign *warn* status to the current test or suite.\n\nReportPortal also provides the corresponding methods for setting status into the launch:\n* setLaunchStatus(*status*). Assign *status* to the launch.<br/>\n*status* should be equal to one of the following values: *passed*, *failed*, *stopped*, *skipped*, *interrupted*, *cancelled*, *info*, *warn*.<br/>\n* cy.setLaunchStatusPassed(). Assign *passed* status to the launch.\n* cy.setLaunchStatusFailed(). Assign *failed* status to the launch.\n* cy.setLaunchStatusSkipped(). Assign *skipped* status to the launch.\n* cy.setLaunchStatusStopped(). Assign *stopped* status to the launch.\n* cy.setLaunchStatusInterrupted(). Assign *interrupted* status to the launch.\n* cy.setLaunchStatusCancelled(). Assign *cancelled* status to the launch.\n* cy.setLaunchStatusInfo(). Assign *info* status to the launch.\n \n## Screenshots support\n\nTo use custom filename in cy.screenshot function you should [setup ReportRortal custom commands](#setup-reportportal-custom-commands).\nDefault usage of Cypress screenshot function is supported without additional setup. \n\n## Automatically merge launches\n\nBy 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.\nThis feature needs information about Cypress configuration. To provide it to the reporter you need to install reportPortal plugin (see how to in [this section](#register-reportportal-plugin-cypresspluginsindexjs)) or to copy the following Cypress config options to the reporterOptions:\n* ignoreTestFiles\n* testFiles\n* integrationFolder\n* fixturesFolder\n* supportFile\n\n*Note: you need to specify only those options that are not the default.*\n\n**Enable auto-merge in reporterOptions as shown below:**\n\n```json\n\n{\n  ...\n  \"reporterOptions\": {\n    ...\n    \"autoMerge\": true\n  }\n}\n\n```\n\n\n## Manual merge launches\n\nThere is a possibility to merge all launches into a single launch in the end of the run.\nWe advice to use [autoMerge option](#automatically-merge-launches) 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.\n\n#### Set corresponding reporter options\n\nEdit cypress.json file. Set isLaunchMergeRequired option to **true** as shown below:\n\n```json\n\n{\n  ...\n  \"reporterOptions\": {\n    ...\n    \"isLaunchMergeRequired\": true\n  }\n}\n\n```\n\n#### Add file to run Cypress with custom behavior\n\nCreate folder \"scripts\" on project folder. Copy the following script into \"cypress.js\" file and put it to \"scripts\"\nfolder.\n\n```javascript\n\nconst cypress = require('cypress');\nconst fs = require('fs');\nconst glob = require('glob');\nconst { mergeLaunches } = require('@reportportal/agent-js-cypress/lib/mergeLaunches');\n\nconst cypressConfigFile = 'cypress.json';\n\nconst getLaunchTempFiles = () => {\n  return glob.sync('rplaunch-*.tmp');\n};\n\nconst deleteTempFile = (filename) => {\n  fs.unlinkSync(filename);\n};\n\ncypress.run().then(\n  () => {\n    fs.readFile(cypressConfigFile, 'utf8', (err, data) => {\n      if (err) {\n        throw err;\n      }\n\n      const config = JSON.parse(data);\n\n      if (config.reporterOptions.isLaunchMergeRequired) {\n        mergeLaunches(config.reporterOptions)\n          .then(() => {\n            const files = getLaunchTempFiles();\n            files.forEach(deleteTempFile);\n            console.log('Launches successfully merged!');\n            process.exit(0);\n          })\n          .catch((err) => {\n            console.error(error);\n            process.exit(1);\n          });\n      } else {\n        process.exit(0);\n      }\n    });\n  },\n  (error) => {\n    console.error(error);\n    const files = getLaunchTempFiles();\n    files.forEach(deleteTempFile);\n    process.exit(1);\n  },\n);\n\n```\n\n#### Update package.json \"scripts\" section\n\n```json\n\n\"scripts\": {\n  ...\n  \"cypress\": \"node scripts/cypress.js\",\n  ...\n},\n\n```\n\n## Parallel execution\n\nCypress can run recorded tests in parallel across multiple machines since version 3.1.0 ([Cypress docs](https://docs.cypress.io/guides/guides/parallelization)). <br/>\nBy 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](#automatically-merge-launches) option together with parallel flag. <br/>\nSince 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](https://docs.cypress.io/guides/guides/parallelization#CI-Build-ID-environment-variables-by-provider) for details).\n\n**Enable parallel in reporterOptions as shown below:**\n\n```json\n\n{\n  ...\n  \"reporterOptions\": {\n    ...\n    \"parallel\": true\n  }\n}\n\n```\n\n**Here's an example of setting up parallel Cypress execution using GitHub Actions:**\n\n```yaml\n\nname: CI-pipeline\n\non:\n  pull_request:\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    container: cypress/browsers:node12.18.3-chrome87-ff82\n    strategy:\n      fail-fast: false\n      matrix:\n        containers: [1, 2, 3]\n    env:\n      CI_BUILD_ID: ${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n\n      - name: 'UI Tests - Chrome'\n        uses: cypress-io/github-action@v2\n        with:\n          config-file: cypress.json\n          group: 'UI Tests - Chrome'\n          spec: cypress/integration/*\n          record: true\n          parallel: true\n        env:\n          CYPRESS_RECORD_KEY: ${{ secrets.RECORD_KEY }}\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          ACTIONS_RUNNER_DEBUG: true\n\n```\n\n# Copyright Notice\n\nLicensed under the [Apache License v2.0](LICENSE)\n","readmeFilename":"README.md"}