Skip to content

An API wrapper for TestRail with error handling and typing.

License

Notifications You must be signed in to change notification settings

dlenroc/node-testrail-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TestRail API GitHub package version Dependencies Status GitHub top language

Installation

npm install @dlenroc/testrail --save

Example

// import TestRail from '@dlenroc/testrail';
// const TestRail = require('@dlenroc/testrail');

const api = new TestRail({
    host: 'https://{organization}.testrail.net',
    username: '{username}',
    password: '{token/password}',
});

const projects = await api.getProjects();

console.log(projects);

APIs

Attachments

addAttachmentToPlan(planId: number, payload: AddAttachment): Promise<CreatedAttachment>;
addAttachmentToPlanEntry(planId: number, entryId: string, payload: AddAttachment): Promise<CreatedAttachment>;
addAttachmentToResult(resultId: number, payload: AddAttachment): Promise<CreatedAttachment>;
addAttachmentToRun(runId: number, payload: AddAttachment): Promise<CreatedAttachment>;
getAttachmentsForCase(caseId: number): Promise<AttachmentForCase[]>;
getAttachmentsForPlan(planId: number): Promise<AttachmentForPlan[]>;
getAttachmentsForPlanEntry(planId: number, entryId: string): Promise<AttachmentForPlanEntry[]>;
getAttachmentsForRun(runId: number): Promise<AttachmentForRun[]>;
getAttachmentsForTest(testId: number): Promise<AttachmentForTest[]>;
getAttachment(attachmentId: number): Promise<Blob>;
deleteAttachment(attachmentId: number): Promise<void>;

Cases

getCase(caseId: number): Promise<Case>;
getCases(projectId: number, filters?: CaseFilters): Promise<Case[]>;
getHistoryForCase(caseId: number): Promise<TestRail.Model.CaseHistory[]>;
addCase(sectionId: number, payload: AddCase): Promise<Case>;
updateCases(suiteId: number, payload: UpdateCases): Promise<void>;
updateCase(caseId: number, payload: UpdateCase): Promise<Case>;
deleteCase(caseId: number): Promise<void>;
deleteCases(suiteId: number, payload: DeleteCases): Promise<void>;

Case Fields

getCaseFields(): Promise<CaseField[]>;
addCaseField(payload: AddCaseField): Promise<CaseField>;

Case Types

getCaseTypes(): Promise<CaseType[]>;

Configurations

getConfigs(projectId: number): Promise<Config[]>;
addConfigGroup(projectId: number, payload: AddConfigGroup): Promise<Config>;
addConfig(configGroupId: number, payload: AddConfig): Promise<ConfigItem>;
updateConfigGroup(configGroupId: number, payload: UpdateConfigGroup): Promise<Config>;
updateConfig(configId: number, payload: UpdateConfig): Promise<ConfigItem>;
deleteConfigGroup(configGroupId: number): Promise<void>;
deleteConfig(configId: number): Promise<void>;

Milestones

getMilestone(milestoneId: number): Promise<Milestone>;
getMilestones(projectId: number, filters?: MilestoneFilters): Promise<Milestone[]>;
addMilestone(projectId: number, payload: AddMilestone): Promise<Milestone>;
updateMilestone(milestoneId: number, payload: UpdateMilestone): Promise<Milestone>;
deleteMilestone(milestoneId: number): Promise<void>;

Plans

getPlan(planId: number): Promise<Plan>;
getPlans(projectId: number, filters?: PlanFilters): Promise<PlanItem[]>;
addPlan(projectId: number, payload: AddPlan): Promise<Plan>;
addPlanEntry(planId: number, payload: AddPlanEntry): Promise<PlanEntry>;
addRunToPlanEntry(planId: number, entryId: string, payload: AddRunToPlanEntry): Promise<PlanEntry>;
updatePlan(planId: number, payload: UpdatePlan): Promise<Plan>;
updatePlanEntry(planId: number, entryId: string, payload: UpdatePlanEntry): Promise<PlanEntry>;
updateRunInPlanEntry(planId: number, runId: number, payload: UpdateRunInPlanEntry): Promise<PlanEntry>;
closePlan(planId: number): Promise<Plan>;
deletePlan(planId: number): Promise<void>;
deletePlanEntry(planId: number, entryId: string): Promise<void>;
deleteRunFromPlanEntry(runId: number): Promise<void>;

Priorities

getPriorities(): Promise<Priority[]>;

Projects

getProject(projectId: number): Promise<Project>;
getProjects(filters?: ProjectFilters): Promise<Project[]>;
addProject(payload: AddProject): Promise<Project>;
updateProject(projectId: number, payload: UpdateProject): Promise<Project>;
deleteProject(projectId: number): Promise<void>;

Reports

getReports(projectId: number): Promise<Report[]>;
runReport(reportTemplateId: number): Promise<ReportUrls>;

Results

getResults(testId: number, filters?: ResultFilters): Promise<Result[]>;
getResultsForCase(runId: number, caseId: number, filters?: ResultFilters): Promise<Result[]>;
getResultsForRun(runId: number, filters?: ResultForRunFilters): Promise<Result[]>;
addResult(testId: number, payload: AddResult): Promise<Result>;
addResultForCase(runId: number, caseId: number, payload: AddResultForCase): Promise<Result>;
addResults(runId: number, payload: AddResults): Promise<Result[]>;
addResultsForCases(runId: number, payload: AddResultsForCases): Promise<Result[]>;

Result Fields

getResultFields(): Promise<ResultField[]>;

Runs

getRun(runId: number): Promise<Run>;
getRuns(projectId: number, filters?: RunFilters): Promise<Run[]>;
addRun(projectId: number, payload: AddRun): Promise<Run>;
updateRun(runId: number, payload: UpdateRun): Promise<Run>;
closeRun(runId: number): Promise<Run>;
deleteRun(runId: number): Promise<void>;

Sections

getSection(sectionId: number): Promise<Section>;
getSections(projectId: number, filters?: SectionFilters): Promise<Section[]>;
addSection(projectId: number, payload: AddSection): Promise<Section>;
updateSection(sectionId: number, payload: UpdateSection): Promise<Section>;
deleteSection(sectionId: number): Promise<void>;

Statuses

getStatuses(): Promise<Status[]>;

Suites

getSuite(suiteId: number): Promise<Suite>;
getSuites(projectId: number): Promise<Suite[]>;
addSuite(projectId: number, payload: AddSuite): Promise<Suite>;
updateSuite(suiteId: number, payload: UpdateSuite): Promise<Suite>;
deleteSuite(suiteId: number): Promise<void>;

Templates

getTemplates(projectId: number): Promise<Template[]>;

Tests

getTest(testId: number): Promise<Test>;
getTests(runId: number, filters?: TestFilters): Promise<Test[]>;

Users

getUser(userId: number): Promise<User>;
getCurrentUser(): Promise<User>;
getUserByEmail(email: string): Promise<User>;
getUsers(filters?: UserFilters): Promise<User[]>;