Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Custom reporter for pushing cypress results to a testrail test run

License

Notifications You must be signed in to change notification settings

deepcrawl/cypress-testrail-reporter

 
 

Repository files navigation

TestRail Reporter for Cypress

Publishes Cypress runs on TestRail.

TODO

  • Solve the problem of the last test not beeing send as mocha evaluates process.exit without waiting for async calls to finish :(
    • Currently solved as adding one test on the end of the test suite that will contain commands: #COMMAND:closeRun# and #COMMAND:noReport#

Install

$ npm install deepcrawl/cypress-testrail-reporter --save-dev
$ yarn add deepcrawl/cypress-testrail-reporter --dev

Usage

Add reporter to your cypress.json:

...
"reporter": "@deepcrawl/cypress-testrail-reporter",
"reporterOptions": {
  "host": "https://yourdomain.testrail.com",
  "username": "username",
  "password": "password",
  "projectId": 1,
  "suiteId": 1,
  "runIdFileLocation": "myFile.txt",
  "environmentName": <string>,
  "cypressProjectId": <string>
}

This reporter automatically looks for a test case with same name and if there is one it uploads the results. If there is no such test case it will make new one and then upload the results.

COMMANDS

#COMMAND:closeRun#

This command notifies the reporter that at AT THE BEGINNING of the test execution the reporter should call test rail to close the run.

describe("Test Rail synchronization test", function () {
  it("this test will call for closing the run #COMMAND:closeRun#", async function () {
    await cy.wait(10000);
    expect(1).equal(1);
  });
});

#COMMAND:noReport#

This command notifies the reporter that this test should not be reported.

describe("Test Rail synchronization test", function () {
  it("this test will call for closing the run #COMMAND:noReport#", async function () {
    await cy.wait(10000);
    expect(1).equal(1);
  });
});

Reporter Options

host: string host of your TestRail instance (e.g. for a hosted instance https://instance.testrail.com).

username: string email of the user under which the test run will be created.

password: string password or the API key for the aforementioned user.

projectId: number project with which the tests are associated in Test Rail.

runIdFileLocation: string name of the file from where the runId should be taken as a priority. If no such file exists than new run will be created and this file will be overrided and the content of the file will be just id of the run. ( This is a solution for cypress to not to create run for each test suite file. )

suiteId: number suite with which the tests are associated.

TestRail Settings

To increase security, the TestRail team suggests using an API key instead of a password. You can see how to generate an API key here.

If you maintain your own TestRail instance on your own server, it is recommended to enable HTTPS for your TestRail installation.

For TestRail hosted accounts maintained by Gurock, all accounts will automatically use HTTPS.

You can read the whole TestRail documentation here.

Author

Deepcrawl internal copy!

License

This project is licensed under the MIT license.

Acknowledgments

About

Custom reporter for pushing cypress results to a testrail test run

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.3%
  • JavaScript 0.7%