An API wrapper for TestRail with error handling and unit testing.
The TestRail API is described here.
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'
});
List cases
testrail.getCases(/*PROJECT_ID=*/1, /*FILTERS=*/{ suite_id: 3, section_id: 4 }, function (err, cases) {
console.log(cases);
});
You can also use Promises with all the functions:
testrail.getCases(1).then(function (cases)
console.log(cases);
}).catch(function (err) {
console.log('error', err);
});
Get a case
testrail.getCase(/*CASE_ID=*/1, function (err, testcase) {
console.log(testcase);
});
Add a case
testrail.addCase(/*SECTION_ID=*/1, /*CONTENT=*/{}, function (err, testcase) {
console.log(testcase);
});
Update a case
testrail.updateCase(/*CASE_ID=*/1, /*CONTENT=*/{}, function (err, testcase) {
console.log(testcase);
});
Delete a case
testrail.deleteCase(/*CASE_ID=*/1, function (err, response) {
console.log(response);
});
List case fields
testrail.getCaseFields(function (err, caseFields) {
console.log(caseFields);
});
List case types
testrail.getCaseTypes(function (err, caseTypes) {
console.log(caseTypes);
});
List configurations
testrail.getConfigs(/*PROJECT_ID=*/1, function (err, configs) {
console.log(configs);
});
Add a configuration group
testrail.addConfigGroup(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, config_group) {
console.log(config_group);
});
Add a configuration
testrail.addConfig(/*CONFIGURATION_GROUP_ID=*/1, /*CONTENT=*/{}, function (err, config) {
console.log(config);
});
Update a configuration group
testrail.updateConfigGroup(/*CONFIGURATION_GROUP_ID=*/1, /*CONTENT=*/{}, function (err, config_group) {
console.log(config_group);
});
Update a configuration
testrail.updateConfig(/*CONFIGURATION_ID=*/1, /*CONTENT=*/{}, function (err, config) {
console.log(config);
});
Delete a configuration group
testrail.deleteConfigurationGroup(/*CONFIGURATION_GROUP_ID=*/1, function (err, response) {
console.log(response);
});
Delete a configuration
testrail.deleteConfig(/*CONFIGURATION_ID=*/1, function (err, response) {
console.log(response);
});
List milestones
testrail.getMilestones(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, milestones) {
console.log(milestones);
});
Get a milestone
testrail.getMilestone(/*MILESTONE_ID=*/1, function (err, milestone) {
console.log(milestone);
});
Add a milestone
testrail.addMilestone(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, milestone) {
console.log(milestone);
});
Update a milestone
testrail.updateMilestone(/*MILESTONE_ID=*/1, /*CONTENT=*/{}, function (err, milestone) {
console.log(milestone);
});
Delete a milestone
testrail.deleteMilestone(/*MILESTONE_ID=*/1, function (err, response) {
console.log(response);
});
List plans
testrail.getPlans(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, plans) {
console.log(plans);
});
Get a plan
testrail.getPlan(/*PLAN_ID=*/1, function (err, plan) {
console.log(plan);
});
Add a plan
testrail.addPlan(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, plan) {
console.log(plan);
});
Add a plan entry
testrail.addPlanEntry(/*PLAN_ID=*/1, /*CONTENT=*/{}, function (err, plan_entry) {
console.log(plan_entry);
});
Update a plan
testrail.updatePlan(/*PLAN_ID=*/1, /*CONTENT=*/{}, function (err, plan) {
console.log(plan);
});
Update a plan entry
testrail.updatePlanEntry(/*PLAN_ID=*/1, /*PLAN_ENTRY_ID=*/2, /*CONTENT=*/{}, function (err, plan_entry) {
console.log(plan_entry);
});
Close a plan
testrail.closePlan(/*PLAN_ID=*/1, function (err, plan) {
console.log(plan);
});
Delete a plan
testrail.deletePlan(/*PLAN_ID=*/1, function (err, response) {
console.log(response);
});
Delete a plan entry
testrail.deletePlanEntry(/*PLAN_ID=*/1, /*PLAN_ENTRY_ID=*/2, function (err, response) {
console.log(response);
});
testrail.getPriorities(function (err, priorities) {
console.log(priorities);
});
List projects
testrail.getProjects(/*FILTERS=*/{}, function (err, projects) {
console.log(projects);
});
Get a project
testrail.getProject(/*PROJECT_ID=*/1, function (err, project) {
console.log(project);
});
Add a project
testrail.addProject(/*CONTENT=*/{}, function (err, project) {
console.log(project);
});
Update a project
testrail.updateProject(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, project) {
console.log(project);
});
Delete a project
testrail.deleteProject(/*PROJECT_ID=*/1, function (err, response) {
console.log(response);
});
Get results
testrail.getResults(/*TEST_ID=*/1, /*FILTERS=*/{}, function (err, results) {
console.log(results);
});
Get results for case
testrail.getResultsForCase(/*RUN_ID=*/1, /*CASE_ID=*/2, /*FILTERS=*/{}, function (err, results) {
console.log(results);
});
Get results for run
testrail.getResultsForRun(/*RUN_ID=*/1, /*FILTERS=*/{}, function (err, results) {
console.log(results);
});
Add a result
testrail.addResult(/*TEST_ID=*/1, /*CONTENT=*/{}, function (err, result) {
console.log(result);
});
Add a result for case
testrail.addResultForCase(/*RUN_ID=*/1, /*CASE_ID=*/2, /*CONTENT=*/{}, function (err, result) {
console.log(result);
});
Add results
testrail.addResults(/*RUN_ID=*/1, /*CONTENT=*/{}, function (err, results) {
console.log(results);
});
Add results for cases
testrail.addResultsForCases(/*RUN_ID=*/1, /*CONTENT=*/{}, function (err, results) {
console.log(results);
});
testrail.getResultFields(function (err, resultFields) {
console.log(resultFields);
});
List runs
testrail.getRuns(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, runs) {
console.log(runs);
});
Get a run
testrail.getRun(/*RUN_ID=*/1, function (err, run) {
console.log(run);
});
Add a run
testrail.addRun(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, run) {
console.log(run);
});
Update a run
testrail.updateRun(/*RUN_ID=*/1, /*CONTENT=*/{}, function (err, run) {
console.log(run);
});
Delete a run
testrail.deleteRun(/*RUN_ID=*/1, function (err, response) {
console.log(response);
});
List sections
testrail.getSections(/*PROJECT_ID=*/1, /*FILTERS=*/{}, function (err, sections) {
console.log(sections);
});
Get a section
testrail.getSection(/*SECTION_ID=*/1, function (err, section) {
console.log(section);
});
Add a section
testrail.addSection(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, section) {
console.log(section);
});
Update a section
testrail.updateSection(/*SECTION_ID=*/1, /*CONTENT=*/{}, function (err, section) {
console.log(section);
});
Delete a section
testrail.deleteSection(/*SECTION_ID=*/1, function (err, response) {
console.log(response);
});
testrail.getStatuses(function (err, statuses) {
console.log(statuses);
});
List suites
testrail.getSuites(/*PROJECT_ID=*/1, function (err, suites) {
console.log(suites);
});
Get a suite
testrail.getSuite(/*SUITE_ID=*/1, function (err, suite) {
console.log(suite);
});
Add a suite
testrail.addSuite(/*PROJECT_ID=*/1, /*CONTENT=*/{}, function (err, suite) {
console.log(suite);
});
Update a suite
testrail.updateSuite(/*SUITE_ID=*/1, /*CONTENT=*/{}, function (err, suite) {
console.log(suite);
});
Delete a suite
testrail.deleteSuite(/*SUITE_ID=*/1, function (err, response) {
console.log(response);
});
testrail.getTemplates(/*PROJECT_ID=*/1, function (err, template) {
console.log(template);
});
List tests
testrail.getTests(/*RUN_ID=*/1, /*FILTERS=*/{}, function (err, tests) {
console.log(tests);
});
Get a test
testrail.getTest(/*TEST_ID=*/1, function (err, test) {
console.log(test);
});
List users
testrail.getUsers(/*FILTERS=*/{}, function (err, users) {
console.log(users);
});
Get a user
testrail.getUser(/*USER_ID=*/1, function (err, user) {
console.log(user);
});
Get a user by email
testrail.getUserByEmail(/*EMAIL=*/'[email protected]', function (err, user) {
console.log(user);
});