Skip to content

Commit

Permalink
Merge pull request awaragi#7 from anas-qa/master
Browse files Browse the repository at this point in the history
add close_run testRail API
  • Loading branch information
mickosav committed Jul 6, 2020
2 parents 24041b6 + 237d6be commit 2c45aa6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/lib/cypress-testrail-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export class CypressTestRailReporter extends reporters.Spec {
return;
}

this.testRail.publishResults(this.results);
// publish test cases results & close the run
this.testRail.publishResults(this.results)
.then(()=> this.testRail.closeRun());
});
}

Expand Down
17 changes: 15 additions & 2 deletions src/lib/testrail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TestRail {
}

public publishResults(results: TestRailResult[]) {
axios({
return axios({
method: 'post',
url: `${this.base}/add_results_for_cases/${this.runId}`,
headers: { 'Content-Type': 'application/json' },
Expand All @@ -61,10 +61,23 @@ export class TestRail {
'\n',
` - Results are published to ${chalk.magenta(
`https://${this.options.domain}/index.php?/runs/view/${this.runId}`
)}`,
)} and test run marked as completed.`,
'\n'
);
})
.catch(error => console.error(error));
}

public closeRun() {
axios({
method: 'post',
url: `${this.base}/close_run/${this.runId}`,
headers: { 'Content-Type': 'application/json' },
auth: {
username: this.options.username,
password: this.options.password,
},
})
.catch(error => console.error(error));
}
}

0 comments on commit 2c45aa6

Please sign in to comment.