New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cypress-testrail

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-testrail

Easy and decoupled Cypress TestRail reporter

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-9.21%
Maintainers
1
Weekly downloads
 
Created
Source

(Super Easy) Cypress TestRail Integration

Build Status NPM Downloads GitHub release (latest by date) NPM License

This integration helps you to automatically send test results to TestRail. And yes, super easy and simple!

Add your TestRail credentials in Cypress, decide which test results should be sent to TestRail and you're done!

1. Installation

npm i cypress-testrail --save-dev

2. Setup TestRail credentials

Now configure your credentials for the TestRail API. Just add this snippet in your Cypress.env.json file and adjust the values. Please keep in mind, the runId is always the test run, that you want to send the results to. You can find the ID inside the test run in TestRail. It usually starts with an R, like "R68".

{
  "testrail": {
    "domain": "my-company.testrail.io",
    "username": "myUser",
    "password": "myPwd"
  }
}

You can also set these variables as ENV variable.

CYPRESS_TESTRAIL_DOMAIN=my-company.testrail.io CYPRESS_TESTRAIL_USERNAME=myUser CYPRESS_TESTRAIL_PASSWORD=myPwd  ./node_modules/.bin/cypress run 

3. Setup Mode

3.1 Send result to specific Run in TestRail

Just assign the RunID of TestRail in your Cypress.env.json and all results will be sent to this run.

Results will only be saved, if the sent TestCaseID is also existing in that run inside TestRail.

{
  "testrail": {
    // ....
    "runId": "12345"
  }
}

You can also set this variable as ENV variable.

CYPRESS_TESTRAIL_RUN_ID=15 ./node_modules/.bin/cypress run 
3.2 Create new Run in TestRail for every Cypress run

Sometimes you want to create test runs dynamically inside TestRail. For this, just assign the ProjectID and the optional MilestoneID of TestRail in your Cypress.env.json.

The integration will then start a new run in TestRail and send the results to this one. It is also possible to provide a custom (or dynamically created) name for the new test run.

{
  "testrail": {
    // ....
    "projectId": "12",                      // required
    "milestoneId": "55",                    // optional
    "runName": "Version XY (%datetime%)",   // optional, use placeholder %datetime% for current date time
    "closeRun": true,                       // optional (default FALSE), automatically close run in this mode
  }
}

You can also set these variables as ENV variable. Here is a sample of 2 variables being used.

CYPRESS_TESTRAIL_PROJECT_ID=2 CYPRESS_TESTRAIL_MILESTONE_ID=15 ./node_modules/.bin/cypress run 
ENV VariableValue
CYPRESS_TESTRAIL_PROJECT_IDyour ID from TestRail
CYPRESS_TESTRAIL_MILESTONE_IDyour ID from TestRail
CYPRESS_TESTRAIL_RUN_NAMEany string
CYPRESS_TESTRAIL_RUN_CLOSEtrue, false

4. Register Plugin

Just place this line in your plugins/index.js file. There's nothing more that is required to register the TestRail reporter.

const TestRailReporter = require('cypress-testrail');

module.exports = (on, config) => {
    new TestRailReporter(on, config).register();
    return config
}

In addition to this, you can register the reporter with a custom comment. That comment will then be sent to the TestRail result along with the other metadata, such as Cypress version, browser, baseURL and more.

const customComment = 'AUT v' + Cypress.env('MY_APP_VERSION');

new TestRailReporter(on, config, customComment).register();

5. Map Test Cases

We're almost done. You can now map TestRail test cases to your Cypress tests. Please use the TestRail case ID as a prefix inside the Cypress test title. The plugin will automatically extract it, and send the results to your test run in TestRail. The case ID needs to be at the beginning and separated with an : from the rest of the title.

it('C123: My Test for TestRail XYZ', () => {

    cy.get('#sw-field--name').type('John');
    // ...
    // ...
    
})

That's it!

You can now start Cypress (restart after config changes), and all your results should be sent to TestRail as soon as your mapped tests pass or fail!

Copying / License

This repository is distributed under the MIT License (MIT). You can find the whole license text in the LICENSE file.

Keywords

FAQs

Package last updated on 09 Aug 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc