Skip to content

Commit 6541903

Browse files
Merge pull request #20828 from timvandermeij/refactor-reporter
Refactor the custom reporters for testing
2 parents 44a6354 + 5fb9f12 commit 6541903

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

test/integration/jasmine-boot.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,29 @@ async function runTests(results) {
5252
jasmineDone(suiteInfo) {},
5353
jasmineStarted(suiteInfo) {},
5454
specDone(result) {
55-
// Report on the result of individual tests.
56-
if (result.status === "excluded") {
55+
// Ignore excluded (fit/xit) or skipped (pending) tests.
56+
if (["excluded", "pending"].includes(result.status)) {
5757
return;
5858
}
59+
60+
// Report on passed or failed tests.
5961
++results.runs;
60-
if (result.failedExpectations.length > 0) {
62+
if (result.status === "passed") {
63+
console.log(`TEST-PASSED | ${result.description}`);
64+
} else {
6165
++results.failures;
6266
console.log(`TEST-UNEXPECTED-FAIL | ${result.description}`);
63-
} else {
64-
console.log(`TEST-PASSED | ${result.description}`);
6567
}
6668
},
6769
specStarted(result) {},
6870
suiteDone(result) {
69-
if (result.status === "excluded") {
71+
// Ignore excluded (fdescribe/xdescribe) or skipped (pending) suites.
72+
if (["excluded", "pending"].includes(result.status)) {
7073
return;
7174
}
72-
// Report on the result of `afterAll` invocations.
73-
if (result.failedExpectations.length > 0) {
75+
76+
// Report on failed suites only (indicates problems in setup/teardown).
77+
if (result.status === "failed") {
7478
++results.failures;
7579
console.log(`TEST-UNEXPECTED-FAIL | ${result.description}`);
7680
}

test/reporter.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ const TestReporter = function (browser) {
6262
this.specStarted = function (result) {};
6363

6464
this.specDone = function (result) {
65-
if (result.status === "excluded") {
65+
// Ignore excluded (fit/xit) or skipped (pending) tests.
66+
if (["excluded", "pending"].includes(result.status)) {
6667
return;
6768
}
68-
// Report on the result of individual tests.
69-
if (result.failedExpectations.length === 0) {
69+
70+
// Report on passed or failed tests.
71+
if (result.status === "passed") {
7072
sendResult("TEST-PASSED", result.description);
7173
} else {
7274
let failedMessages = "";
@@ -78,11 +80,13 @@ const TestReporter = function (browser) {
7880
};
7981

8082
this.suiteDone = function (result) {
81-
if (result.status === "excluded") {
83+
// Ignore excluded (fdescribe/xdescribe) or skipped (pending) suites.
84+
if (["excluded", "pending"].includes(result.status)) {
8285
return;
8386
}
84-
// Report on the result of `afterAll` invocations.
85-
if (result.failedExpectations.length > 0) {
87+
88+
// Report on failed suites only (indicates problems in setup/teardown).
89+
if (result.status === "failed") {
8690
let failedMessages = "";
8791
for (const item of result.failedExpectations) {
8892
failedMessages += `${item.message} `;

0 commit comments

Comments
 (0)