JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12144
  • Score
    100M100P100Q137081F
  • License MIT

JavaScript client for TestRail API

Package Exports

  • testrail-api-client

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (testrail-api-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

testrail-api-client

TypeScript and JavaScript binding for TestRail API v2

Node.js Package npm version npm downloads

Installing

Using npm:

$ npm install testrail-api-client

Using yarn:

$ yarn add testrail-api-client

Example

note: CommonJS usage

Using Environment Variables:

const client = require('testrail-api-client');

Using Custom Options:

const client_options = require('testrail-api-client').default;

const options = {
    domain: "example.testrail.com",
    username: "example@example.com",
    password: "ABC",
    projectId: 1
};

const client = new client_options(options);

addRun

const runName = "Example Run Name";
const runDescription = "Example Run Description";
const testSuiteId = 1;
const caseIds = [1,2,3];
client.addRun(runName, runDescription, testSuiteId, caseIds)
  .then(function (runId) {
      console.log(`Created run with id: ${runId}`)
  })
  .catch(error => console.error(error));

getCasesFromRun

const runId = 123;
client.getCasesFromRun(runId)
  .then(function (cases) {
      console.log(`Number of cases from run #${runId}: ${cases.length}`)
  })
  .catch(error => console.error(error));

closeRun

const runId = 123;
client.closeRun(runId)
  .then(console.log(`Closed run with id: ${runId}`))
  .catch(error => console.error(error));

getCases

const suiteId = 1;
client.getCases(suiteId)
  .then(function (cases) {
      console.log(`Number of cases in suiteid=${suiteId}: ${cases.length}`);
  })
  .catch(error => console.error(error));

Environment variables

Variable Description
TESTRAIL_DOMAIN This is a required variable to point the client to your TestRail instance.

Required
Example: example.testrail.com
TESTRAIL_USERNAME This is a required variable to authenticate HTTP communication.

Required
Example: example@example.com
TESTRAIL_APIKEY This is a required variable to authenticate HTTP communication. Can be obtained in TestRail settings, see [http://docs.gurock.com/testrail-api2/accessing].

Required
Example: ABC
TESTRAIL_PROJECTID This is a required variable to point client to the right project.

Required
Example: 1