Merge pull request #34 from malithmcr/master

fix: added refs field support
This commit is contained in:
Milos Janjic
2022-11-15 13:55:17 +01:00
committed by GitHub
8 changed files with 1341 additions and 8 deletions

View File

@@ -78,6 +78,10 @@ environment variables, this option would be overwritten with it.
**groupId**: _string_ (optional: needs "includeAllInTestRun": false ) The ID of the section/group. When you set `CYPRESS_TESTRAIL_REPORTER_GROUPID` in runtime environment variables, this option would be overwritten with it.
**refs**: _string_ (optional: default is "") Ref of test run to create
When you set `CYPRESS_TESTRAIL_REPORTER_REFS` in runtime environment variables, this option would be overwritten with it.
A comma-separated list of references/requirements — requires TestRail 6.1 or later.
**filter**: _string_ (optional: needs "includeAllInTestRun": false) Only return cases with matching filter string in the case title
## Multiple suite

View File

@@ -46,6 +46,9 @@ var CypressTestRailReporter = /** @class */ (function (_super) {
if (process.env.CYPRESS_TESTRAIL_REPORTER_GROUPID) {
_this.reporterOptions.runName = process.env.CYPRESS_TESTRAIL_REPORTER_GROUPID;
}
if (process.env.CYPRESS_TESTRAIL_REPORTER_REFS) {
_this.reporterOptions.refs = process.env.CYPRESS_TESTRAIL_REPORTER_REFS;
}
_this.testRailApi = new testrail_1.TestRail(_this.reporterOptions);
_this.testRailValidation = new testrail_validation_1.TestRailValidation(_this.reporterOptions);
/**
@@ -101,7 +104,7 @@ var CypressTestRailReporter = /** @class */ (function (_super) {
}
}
TestRailLogger.log("Creating TestRail Run with name: " + name_1);
_this.testRailApi.createRun(name_1, description, _this.suiteId);
_this.testRailApi.createRun(name_1, description, _this.suiteId, _this.reporterOptions.refs);
}
else {
// use the cached TestRail Run ID

File diff suppressed because one or more lines are too long

3
dist/testrail.js vendored
View File

@@ -108,7 +108,7 @@ var TestRail = /** @class */ (function () {
})
.catch(function (error) { return console.error(error); }));
};
TestRail.prototype.createRun = function (name, description, suiteId) {
TestRail.prototype.createRun = function (name, description, suiteId, refs) {
var _this = this;
if (this.options.includeAllInTestRun === false) {
this.includeAll = false;
@@ -125,6 +125,7 @@ var TestRail = /** @class */ (function () {
data: JSON.stringify({
suite_id: suiteId,
name: name,
refs: refs !== null && refs !== void 0 ? refs : "",
description: description,
include_all: this.includeAll,
case_ids: this.caseIds

File diff suppressed because one or more lines are too long

1324
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -39,6 +39,10 @@ export class CypressTestRailReporter extends reporters.Spec {
this.reporterOptions.runName = process.env.CYPRESS_TESTRAIL_REPORTER_GROUPID;
}
if (process.env.CYPRESS_TESTRAIL_REPORTER_REFS) {
this.reporterOptions.refs = process.env.CYPRESS_TESTRAIL_REPORTER_REFS;
}
this.testRailApi = new TestRail(this.reporterOptions);
this.testRailValidation = new TestRailValidation(this.reporterOptions);
@@ -94,7 +98,7 @@ export class CypressTestRailReporter extends reporters.Spec {
}
}
TestRailLogger.log(`Creating TestRail Run with name: ${name}`);
this.testRailApi.createRun(name, description, this.suiteId);
this.testRailApi.createRun(name, description, this.suiteId, this.reporterOptions.refs);
} else {
// use the cached TestRail Run ID
this.runId = TestRailCache.retrieve('runId');

View File

@@ -62,7 +62,7 @@ export class TestRail {
)
}
public createRun (name: string, description: string, suiteId: number) {
public createRun (name: string, description: string, suiteId: number, refs?: string) {
if (this.options.includeAllInTestRun === false){
this.includeAll = false;
this.caseIds = this.getCases(suiteId);
@@ -79,6 +79,7 @@ export class TestRail {
data: JSON.stringify({
suite_id: suiteId,
name,
refs: refs ?? "",
description,
include_all: this.includeAll,
case_ids: this.caseIds