npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

testrail-api

v1.3.6

Published

A complete API wrapper for TestRail - with 100% code coverage

Downloads

288,612

Readme

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=*/'[email protected]', function (err, response, user) {
  console.log(user);
});