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
Installing
Using npm:
$ npm install testrail-api-clientUsing yarn:
$ yarn add testrail-api-clientExample
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 |