@decathlon/newman-reporter-pullrequest-decorator
Advanced tools
Comparing version 0.0.24 to 0.0.25
@@ -5,2 +5,4 @@ # Changelog | ||
### 0.0.25 (2023-11-02) | ||
### 0.0.24 (2023-11-01) | ||
@@ -7,0 +9,0 @@ |
@@ -73,6 +73,5 @@ const HEADER_STARTING_NUMBER = 2; | ||
const buildFailureComment = (commentParam, report) => { | ||
const buildFailureComment = (commentParam, failures) => { | ||
let comment = commentParam; | ||
report.items | ||
.filter((item) => item.test_status === 'FAIL') | ||
failures | ||
.forEach((item, index) => { | ||
@@ -90,14 +89,35 @@ if (index === 0) { | ||
const evaluateResult = (result, items) => { | ||
if (isLeafLevel(items)) { // folder with requests | ||
result.requestsFailed.push(...items.filter((request) => request.test_status === 'FAIL')); | ||
result.requestsPassed += items.filter((request) => request.test_status === 'PASS').length; // eslint-disable-line no-param-reassign | ||
result.requestsSkipped += items.filter((request) => request.test_status === 'SKIP').length; // eslint-disable-line no-param-reassign | ||
} else if (isParentLevel(items)) { // folder of folders | ||
items.forEach((folder) => { | ||
evaluateResult(result, folder.subItems); | ||
}); | ||
} | ||
return { | ||
...result, | ||
requestsFailed: result.requestsFailed.map((requestFailed) => ({ ...requestFailed })), | ||
}; | ||
}; | ||
const buildPullRequestComment = (report, options, issueNumber, checkRunId) => { | ||
const { items } = report; | ||
const requestsFailedCount = report.items.filter((item) => item.test_status === 'FAIL').length; | ||
const requestsSkippedCount = report.items.filter((item) => item.test_status === 'SKIP').length; | ||
const initialCount = { | ||
requestsFailed: [], | ||
requestsSkipped: 0, | ||
requestsPassed: 0, | ||
}; | ||
const { requestsFailed, requestsSkipped, requestsPassed } = evaluateResult(initialCount, items); | ||
const totalRequests = requestsFailed.length + requestsSkipped + requestsPassed; | ||
const comment = `Please find the complete report [here](${buildCheckPageUrl(options, issueNumber, checkRunId)}) | ||
✅ ${items.length - (requestsFailedCount) - requestsSkippedCount} / ${items.length} **Requests Passed** | ||
❌ ${requestsFailedCount} / ${items.length} **Requests Failed** | ||
⏩ ${(requestsSkippedCount)} / ${items.length} **Requests Skipped**`; | ||
✅ ${requestsPassed} / ${totalRequests} **Requests Passed** | ||
❌ ${requestsFailed.length} / ${totalRequests} **Requests Failed** | ||
⏩ ${(requestsSkipped)} / ${totalRequests} **Requests Skipped**`; | ||
return requestsFailedCount > 0 | ||
? (`You have some failing tests \n ${buildFailureComment(comment, report)}`) | ||
return requestsFailed.length > 0 | ||
? (`You have some failing tests \n ${buildFailureComment(comment, requestsFailed)}`) | ||
: (`Congratulations, All Tests have Passed! \n${comment}`); | ||
@@ -104,0 +124,0 @@ }; |
{ | ||
"name": "@decathlon/newman-reporter-pullrequest-decorator", | ||
"license": "Apache-2.0", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "Newman reporter allowing to decorate Github's PullRequest with postman collection results", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45803
318