Skip to content

Commit

Permalink
feat: add test duration in TestRail (#31)
Browse files Browse the repository at this point in the history
* feat: add test duration in TestRail

* fix: error code style

* fix: define a default value for test duration

* feat: add default value for elapsed

* revert: feat: add default value for elapsed

* fix: push elapsed value only if it is defined

* chore: prettier

* fix: replace toStrictEqual by toEqual

Co-authored-by: Jérémy Torralba <[email protected]>
  • Loading branch information
trooperjey01 and jeremyagatha authored Oct 8, 2021
1 parent 1ac4ec4 commit 267fcbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,15 @@ class TestcafeTestrailReporter {
return formatted;
})
.join("\n");

let testDuration;
if (testRunInfo.durationMs > 0) {
testDuration = (testRunInfo.durationMs / 1000).toString() + "s";
}
this.results.push({
case_id: caseId,
status_id: testStatus.value,
comment: `Test ${testStatus.text}\n${errorLog}`,
elapsed: testDuration,
});
if (testRunInfo.screenshots.length) {
this.screenshots[caseId] = testRunInfo.screenshots;
Expand Down
10 changes: 5 additions & 5 deletions tests/reporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe("Reporter Plugin", () => {
testInfo,
meta
);
expect(plugin.reporter.results).toStrictEqual(expected);
expect(plugin.reporter.results).toEqual(expected);
expect(logMock).toBeCalledTimes(0);
expect(errorMock).toBeCalledTimes(0);
expect(fetchMock).toBeCalledTimes(0);
Expand Down Expand Up @@ -155,7 +155,7 @@ describe("Reporter Plugin", () => {
testInfo,
meta
);
expect(plugin.reporter.results).toStrictEqual(expected);
expect(plugin.reporter.results).toEqual(expected);
expect(logMock).toBeCalledTimes(0);
expect(errorMock).toBeCalledTimes(0);
expect(fetchMock).toBeCalledTimes(0);
Expand Down Expand Up @@ -186,7 +186,7 @@ describe("Reporter Plugin", () => {
testInfo,
meta
);
expect(plugin.reporter.results).toStrictEqual(expected);
expect(plugin.reporter.results).toEqual(expected);
expect(logMock).toBeCalledTimes(0);
expect(errorMock).toBeCalledTimes(0);
expect(fetchMock).toBeCalledTimes(0);
Expand Down Expand Up @@ -218,7 +218,7 @@ describe("Reporter Plugin", () => {
testInfo,
meta
);
expect(plugin.reporter.results).toStrictEqual(expectedResult);
expect(plugin.reporter.results).toEqual(expectedResult);
expect(plugin.reporter.screenshots).toStrictEqual(expectedScreenshots);
expect(logMock).toBeCalledTimes(0);
expect(errorMock).toBeCalledTimes(0);
Expand Down Expand Up @@ -257,7 +257,7 @@ describe("Reporter Plugin", () => {
testInfo,
meta
);
expect(plugin.reporter.results).toStrictEqual(expectedResult);
expect(plugin.reporter.results).toEqual(expectedResult);
expect(logMock).toBeCalledTimes(0);
expect(errorMock).toBeCalledTimes(0);
expect(fetchMock).toBeCalledTimes(0);
Expand Down

0 comments on commit 267fcbf

Please sign in to comment.