1.0.28 • Published 3 months ago

testrail-api-client v1.0.28

Weekly downloads
868
License
MIT
Repository
github
Last release
3 months ago

testrail-api-client

TypeScript and JavaScript binding for TestRail API v2

npm version Coverage Status 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",
};

const client = new client_options(options);

addRun

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

getTests

const runId = 123;
client
  .getTests(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 projectId = 1;
const suiteId = 123; // optional
client
  .getCases(projectId, suiteId)
  .then(function (cases) {
    console.log(`Number of cases in suiteid=${suiteId}: ${cases.length}`);
  })
  .catch((error) => console.error(error));

addResultsForCases

const runId = 123;
const reportTests = [{ case_id: 12345, status_id: 1, comment: "Test comment" }];
client
  .addResultsForCases(runId, reportTests)
  .then(() => {
    console.log("Done");
  })
  .catch((err) => {
    console.log(err);
  });

updateRunDescription

const runId = 123;
const description = "Run Description";
client
  .updateRunDescription(runId, description)
  .then(() => {
    console.log("Done");
  })
  .catch((err) => {
    console.log(err);
  });

addAttachmentToResult

const runId = 123;
client
  .addAttachmentToResult(runId, '../testrail-api-client/README.md')
  .then((response) => {
    console.log("Done", response);
  })
  .catch((err) => {
    console.log(err);
  });

Environment variables

VariableDescription
TESTRAIL_DOMAINThis is a required variable to point the client to your TestRail instance.RequiredExample: example.testrail.com
TESTRAIL_USERNAMEThis is a required variable to authenticate HTTP communication.RequiredExample: example@example.com
TESTRAIL_APIKEYThis is a required variable to authenticate HTTP communication. Can be obtained in TestRail settings, see http://docs.gurock.com/testrail-api2/accessing.RequiredExample: ABC
TESTRAIL_PROJECTIDThis is a required variable to point client to the right project.RequiredExample: 1
1.0.28

3 months ago

1.0.27

3 months ago

1.0.22

6 months ago

1.0.24

6 months ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago