Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

testrail-api

1.3.5 • Public • Published

testrail-api

npm version Travis Coverage Status

An API wrapper for TestRail with error handling and unit testing.

The TestRail API is described here.

Usage

First, you will have to initialize the API wrapper :

var Testrail = require('testrail-api');
 
var testrail = new Testrail({
  host: 'https://rundef.testrail.com',
  user: 'username',
  password: 'password or api key'
});

Callback

Working with callbacks gives you three parameters: error, response and body in this order

function (err, response, body)

error is null when nothing unexpected happened.

response contains data like the status code.

body contains the response body the server sent back.

Promises

Working with Promises gives you response and body like this

  .then(function (result) {
    console.log(result.response);
    console.log(result.body);
  })
  .catch(function (error) {
    console.log(error.response);
    console.log(error.message);
  });

Cases

List cases

testrail.getCases(/*PROJECT_ID=*/1, /*FILTERS=*/{ suite_id: 3, section_id: 4 }, function (err, response, cases) {
  console.log(cases);
});

You can also use Promises with all the functions:

testrail.getCases(1)
  .then(function (result) {
    console.log(result.body);
  }).catch(function (error) {
    console.log('error', error.message);
  });

Get a case

testrail.getCase(/*CASE_ID=*/1, function (err, response, testcase) {
  console.log(testcase);
});

Add a case

testrail.addCase(/*SECTION_ID=*/1, /*CONTENT=*/{}, function (err, response, testcase) {
  console.log(testcase);
});

Update a case

testrail.updateCase(/*CASE_ID=*/1, /*CONTENT=*/{}, function (err, response, testcase) {
  console.log(testcase);
});

Delete a case

testrail.deleteCase(/*CASE_ID=*/1, function (err, response, body) {
  console.log(body);
});

Case Fields

List case fields

testrail.getCaseFields(function (err, response, caseFields) {
  console.log(caseFields);
});

Case Types

List case types

testrail.getCaseTypes(function (err, response, caseTypes) {
  console.log(caseTypes);
});

Configurations

List configurations

testrail.getConfigs(/*PROJECT_ID=*/1, function (err, response, configs) {
  console.log(configs);
});

Add a configuration group

testrail.addConfigGroup(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, response, config_group) {
  console.log(config_group);
});

Add a configuration

testrail.addConfig(/*CONFIGURATION_GROUP_ID=*/1, /*CONTENT=*/{}, function (err, response, config) {
  console.log(config);
});

Update a configuration group

testrail.updateConfigGroup(/*CONFIGURATION_GROUP_ID=*/1, /*CONTENT=*/{}, function (err, response, config_group) {
  console.log(config_group);
});

Update a configuration

testrail.updateConfig(/*CONFIGURATION_ID=*/1, /*CONTENT=*/{}, function (err, response, config) {
  console.log(config);
});

Delete a configuration group

testrail.deleteConfigurationGroup(/*CONFIGURATION_GROUP_ID=*/1, function (err, response, body) {
  console.log(body);
});

Delete a configuration

testrail.deleteConfig(/*CONFIGURATION_ID=*/1, function (err, response, body) {
  console.log(body);
});

Milestones

List milestones

testrail.getMilestones(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, response, milestones) {
  console.log(milestones);
});

Get a milestone

testrail.getMilestone(/*MILESTONE_ID=*/1, function (err, response, milestone) {
  console.log(milestone);
});

Add a milestone

testrail.addMilestone(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, response, milestone) {
  console.log(milestone);
});

Update a milestone

testrail.updateMilestone(/*MILESTONE_ID=*/1, /*CONTENT=*/{}, function (err, response, milestone) {
  console.log(milestone);
});

Delete a milestone

testrail.deleteMilestone(/*MILESTONE_ID=*/1, function (err, response, body) {
  console.log(body);
});

Plans

List plans

testrail.getPlans(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, response, plans) {
  console.log(plans);
});

Get a plan

testrail.getPlan(/*PLAN_ID=*/1, function (err, response, plan) {
  console.log(plan);
});

Add a plan

testrail.addPlan(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, response, plan) {
  console.log(plan);
});

Add a plan entry

testrail.addPlanEntry(/*PLAN_ID=*/1, /*CONTENT=*/{}, function (err, response, plan_entry) {
  console.log(plan_entry);
});

Update a plan

testrail.updatePlan(/*PLAN_ID=*/1, /*CONTENT=*/{}, function (err, response, plan) {
  console.log(plan);
});

Update a plan entry

testrail.updatePlanEntry(/*PLAN_ID=*/1, /*PLAN_ENTRY_ID=*/2, /*CONTENT=*/{}, function (err, response, plan_entry) {
  console.log(plan_entry);
});

Close a plan

testrail.closePlan(/*PLAN_ID=*/1, function (err, response, plan) {
  console.log(plan);
});

Delete a plan

testrail.deletePlan(/*PLAN_ID=*/1, function (err, response, body) {
  console.log(body);
});

Delete a plan entry

testrail.deletePlanEntry(/*PLAN_ID=*/1, /*PLAN_ENTRY_ID=*/2, function (err, response, body) {
  console.log(body);
});

Priorities

testrail.getPriorities(function (err, response, priorities) {
  console.log(priorities);
});

Projects

List projects

testrail.getProjects(/*FILTERS=*/{}, function (err, response, projects) {
  console.log(projects);
});

Get a project

testrail.getProject(/*PROJECT_ID=*/1, function (err, response, project) {
  console.log(project);
});

Add a project

testrail.addProject(/*CONTENT=*/{}, function (err, response, project) {
  console.log(project);
});

Update a project

testrail.updateProject(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, response, project) {
  console.log(project);
});

Delete a project

testrail.deleteProject(/*PROJECT_ID=*/1, function (err, response, body) {
  console.log(body);
});

Results

Get results

testrail.getResults(/*TEST_ID=*/1, /*FILTERS=*/{}, function (err, response, results) {
  console.log(results);
});

Get results for case

testrail.getResultsForCase(/*RUN_ID=*/1, /*CASE_ID=*/2, /*FILTERS=*/{}, function (err, response, results) {
  console.log(results);
});

Get results for run

testrail.getResultsForRun(/*RUN_ID=*/1, /*FILTERS=*/{}, function (err, response, results) {
  console.log(results);
});

Add a result

testrail.addResult(/*TEST_ID=*/1, /*CONTENT=*/{}, function (err, response, result) {
  console.log(result);
});

Add a result for case

testrail.addResultForCase(/*RUN_ID=*/1, /*CASE_ID=*/2, /*CONTENT=*/{}, function (err, response, result) {
  console.log(result);
});

Add results

testrail.addResults(/*RUN_ID=*/1, /*CONTENT=*/{}, function (err, response, results) {
  console.log(results);
});

Add results for cases

testrail.addResultsForCases(/*RUN_ID=*/1, /*CONTENT=*/{}, function (err, response, results) {
  console.log(results);
});

Result Fields

testrail.getResultFields(function (err, response, resultFields) {
  console.log(resultFields);
});

Runs

List runs

testrail.getRuns(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, response, runs) {
  console.log(runs);
});

Get a run

testrail.getRun(/*RUN_ID=*/1, function (err, response, run) {
  console.log(run);
});

Add a run

testrail.addRun(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, response, run) {
  console.log(run);
});

Update a run

testrail.updateRun(/*RUN_ID=*/1, /*CONTENT=*/{}, function (err, response, run) {
  console.log(run);
});

Close a run

testrail.closeRun(/*RUN_ID=*/1, function (err, response, run) {
  console.log(run);
});

Delete a run

testrail.deleteRun(/*RUN_ID=*/1, function (err, response, body) {
  console.log(body);
});

Sections

List sections

testrail.getSections(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, response, sections) {
  console.log(sections);
});

Get a section

testrail.getSection(/*SECTION_ID=*/1, function (err, response, section) {
  console.log(section);
});

Add a section

testrail.addSection(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, response, section) {
  console.log(section);
});

Update a section

testrail.updateSection(/*SECTION_ID=*/1, /*CONTENT=*/{}, function (err, response, section) {
  console.log(section);
});

Delete a section

testrail.deleteSection(/*SECTION_ID=*/1, function (err, response, body) {
  console.log(body);
});

Statuses

testrail.getStatuses(function (err, response, statuses) {
  console.log(statuses);
});

Suites

List suites

testrail.getSuites(/*PROJECT_ID=*/1, function (err, response, suites) {
  console.log(suites);
});

Get a suite

testrail.getSuite(/*SUITE_ID=*/1, function (err, response, suite) {
  console.log(suite);
});

Add a suite

testrail.addSuite(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, response, suite) {
  console.log(suite);
});

Update a suite

testrail.updateSuite(/*SUITE_ID=*/1, /*CONTENT=*/{}, function (err, response, suite) {
  console.log(suite);
});

Delete a suite

testrail.deleteSuite(/*SUITE_ID=*/1, function (err, response, body) {
  console.log(body);
});

Templates

testrail.getTemplates(/*PROJECT_ID=*/1, function (err, response, template) {
  console.log(template);
});

Tests

List tests

testrail.getTests(/*RUN_ID=*/1, /*FILTERS=*/{}, function (err, response, tests) {
  console.log(tests);
});

Get a test

testrail.getTest(/*TEST_ID=*/1, function (err, response, test) {
  console.log(test);
});

Users

List users

testrail.getUsers(/*FILTERS=*/{}, function (err, response, users) {
  console.log(users);
});

Get a user

testrail.getUser(/*USER_ID=*/1, function (err, response, user) {
  console.log(user);
});

Get a user by email

testrail.getUserByEmail(/*EMAIL=*/'test@gmail.com', function (err, response, user) {
  console.log(user);
});

Keywords

install

npm i testrail-api

Downloadsweekly downloads

2,814

version

1.3.5

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability