mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
Manually create anchors for headings
This commit is contained in:
parent
3e8db1a67b
commit
95d3d1fb85
8 changed files with 82 additions and 156 deletions
|
|
@ -5,11 +5,11 @@ exports[`jest-junit tests matches report snapshot 1`] = `
|
||||||
**6** tests were completed in **1.360s** with **1** passed, **1** skipped and **4** failed.
|
**6** tests were completed in **1.360s** with **1** passed, **1** skipped and **4** failed.
|
||||||
| Result | Suite | Tests | Time | Passed ✔️ | Failed ❌ | Skipped ✖️ |
|
| Result | Suite | Tests | Time | Passed ✔️ | Failed ❌ | Skipped ✖️ |
|
||||||
| :---: | :--- | ---: | ---: | ---: | ---: | ---: |
|
| :---: | :--- | ---: | ---: | ---: | ---: | ---: |
|
||||||
| ❌ | [__tests__\\\\main.test.js](#testsmaintestjs-) | 4 | 0.486s | 1 | 3 | 0 |
|
| ❌ | [__tests__\\\\main.test.js](#ts-0-tests-main-test-js) | 4 | 0.486s | 1 | 3 | 0 |
|
||||||
| ❌ | [__tests__\\\\second.test.js](#testssecondtestjs-) | 2 | 0.082s | 0 | 1 | 1 |
|
| ❌ | [__tests__\\\\second.test.js](#ts-1-tests-second-test-js) | 2 | 0.082s | 0 | 1 | 1 |
|
||||||
## Test Suites
|
## Test Suites
|
||||||
|
|
||||||
### __tests__\\\\main.test.js ❌
|
### <a id=\\"user-content-ts-0-tests-main-test-js\\" href=\\"#ts-0-tests-main-test-js\\">__tests__\\\\main.test.js</a> ❌
|
||||||
|
|
||||||
#### Test 1
|
#### Test 1
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ exports[`jest-junit tests matches report snapshot 1`] = `
|
||||||
| :---: | :--- | ---: | --- |
|
| :---: | :--- | ---: | --- |
|
||||||
| ❌ | Exception in test | 0ms | <details><summary>Error: Some error</summary><pre> at Object.<anonymous> (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\__tests__\\\\main.test.js:21:11)<br> at Object.asyncJestTest (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\jasmineAsyncInstall.js:106:37)<br> at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:45:12<br> at new Promise (<anonymous>)<br> at mapper (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:28:19)<br> at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:75:41<br> at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre></details> |
|
| ❌ | Exception in test | 0ms | <details><summary>Error: Some error</summary><pre> at Object.<anonymous> (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\__tests__\\\\main.test.js:21:11)<br> at Object.asyncJestTest (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\jasmineAsyncInstall.js:106:37)<br> at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:45:12<br> at new Promise (<anonymous>)<br> at mapper (C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:28:19)<br> at C:\\\\Users\\\\Michal\\\\Workspace\\\\dorny\\\\test-check\\\\reports\\\\jest\\\\node_modules\\\\jest-jasmine2\\\\build\\\\queueRunner.js:75:41<br> at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre></details> |
|
||||||
|
|
||||||
### __tests__\\\\second.test.js ❌
|
### <a id=\\"user-content-ts-1-tests-second-test-js\\" href=\\"#ts-1-tests-second-test-js\\">__tests__\\\\second.test.js</a> ❌
|
||||||
|
|
||||||
| Result | Test | Time | Details |
|
| Result | Test | Time | Details |
|
||||||
| :---: | :--- | ---: | --- |
|
| :---: | :--- | ---: | --- |
|
||||||
|
|
|
||||||
133
dist/index.js
generated
vendored
133
dist/index.js
generated
vendored
|
|
@ -83,18 +83,15 @@ run();
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 1113:
|
/***/ 1113:
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.parseJestJunit = void 0;
|
exports.parseJestJunit = void 0;
|
||||||
const xml2js_1 = __webpack_require__(6189);
|
const xml2js_1 = __webpack_require__(6189);
|
||||||
const github_slugger_1 = __importDefault(__webpack_require__(237));
|
|
||||||
const markdown_utils_1 = __webpack_require__(6482);
|
const markdown_utils_1 = __webpack_require__(6482);
|
||||||
|
const slugger_1 = __webpack_require__(3328);
|
||||||
const xml_utils_1 = __webpack_require__(8653);
|
const xml_utils_1 = __webpack_require__(8653);
|
||||||
async function parseJestJunit(content) {
|
async function parseJestJunit(content) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
|
|
@ -102,18 +99,17 @@ async function parseJestJunit(content) {
|
||||||
attrValueProcessors: [xml_utils_1.parseAttribute]
|
attrValueProcessors: [xml_utils_1.parseAttribute]
|
||||||
}));
|
}));
|
||||||
const testsuites = junit.testsuites;
|
const testsuites = junit.testsuites;
|
||||||
const slugger = new github_slugger_1.default();
|
|
||||||
const success = !(((_a = testsuites.$) === null || _a === void 0 ? void 0 : _a.failures) > 0 || ((_b = testsuites.$) === null || _b === void 0 ? void 0 : _b.errors) > 0);
|
const success = !(((_a = testsuites.$) === null || _a === void 0 ? void 0 : _a.failures) > 0 || ((_b = testsuites.$) === null || _b === void 0 ? void 0 : _b.errors) > 0);
|
||||||
return {
|
return {
|
||||||
success,
|
success,
|
||||||
output: {
|
output: {
|
||||||
title: junit.testsuites.$.name,
|
title: junit.testsuites.$.name,
|
||||||
summary: getSummary(success, junit, slugger)
|
summary: getSummary(success, junit)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
exports.parseJestJunit = parseJestJunit;
|
exports.parseJestJunit = parseJestJunit;
|
||||||
function getSummary(success, junit, slugger) {
|
function getSummary(success, junit) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
const stats = junit.testsuites.$;
|
const stats = junit.testsuites.$;
|
||||||
const icon = success ? markdown_utils_1.Icon.success : markdown_utils_1.Icon.fail;
|
const icon = success ? markdown_utils_1.Icon.success : markdown_utils_1.Icon.fail;
|
||||||
|
|
@ -123,26 +119,26 @@ function getSummary(success, junit, slugger) {
|
||||||
const passed = stats.tests - failed - skipped;
|
const passed = stats.tests - failed - skipped;
|
||||||
const heading = `# ${stats.name} ${icon}`;
|
const heading = `# ${stats.name} ${icon}`;
|
||||||
const headingLine = `**${stats.tests}** tests were completed in **${time}** with **${passed}** passed, **${skipped}** skipped and **${failed}** failed.`;
|
const headingLine = `**${stats.tests}** tests were completed in **${time}** with **${passed}** passed, **${skipped}** skipped and **${failed}** failed.`;
|
||||||
const suitesSummary = junit.testsuites.testsuite.map(ts => {
|
const suitesSummary = junit.testsuites.testsuite.map((ts, i) => {
|
||||||
const skip = ts.$.skipped;
|
const skip = ts.$.skipped;
|
||||||
const fail = ts.$.errors + ts.$.failures;
|
const fail = ts.$.errors + ts.$.failures;
|
||||||
const pass = ts.$.tests - fail - skip;
|
const pass = ts.$.tests - fail - skip;
|
||||||
const tm = `${ts.$.time.toFixed(3)}s`;
|
const tm = `${ts.$.time.toFixed(3)}s`;
|
||||||
const result = success ? markdown_utils_1.Icon.success : markdown_utils_1.Icon.fail;
|
const result = success ? markdown_utils_1.Icon.success : markdown_utils_1.Icon.fail;
|
||||||
const slug = slugger.slug(`${ts.$.name} ${result}`).replace(/_/g, '');
|
const tsName = ts.$.name;
|
||||||
const tsAddr = `#${slug}`;
|
const tsAddr = makeSuiteSlug(i, tsName).link;
|
||||||
const name = markdown_utils_1.link(ts.$.name, tsAddr);
|
const tsNameLink = markdown_utils_1.link(tsName, tsAddr);
|
||||||
return [result, name, ts.$.tests, tm, pass, fail, skip];
|
return [result, tsNameLink, ts.$.tests, tm, pass, fail, skip];
|
||||||
});
|
});
|
||||||
const summary = markdown_utils_1.table(['Result', 'Suite', 'Tests', 'Time', `Passed ${markdown_utils_1.Icon.success}`, `Failed ${markdown_utils_1.Icon.fail}`, `Skipped ${markdown_utils_1.Icon.skip}`], [markdown_utils_1.Align.Center, markdown_utils_1.Align.Left, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right], ...suitesSummary);
|
const summary = markdown_utils_1.table(['Result', 'Suite', 'Tests', 'Time', `Passed ${markdown_utils_1.Icon.success}`, `Failed ${markdown_utils_1.Icon.fail}`, `Skipped ${markdown_utils_1.Icon.skip}`], [markdown_utils_1.Align.Center, markdown_utils_1.Align.Left, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right, markdown_utils_1.Align.Right], ...suitesSummary);
|
||||||
const suites = (_b = (_a = junit.testsuites) === null || _a === void 0 ? void 0 : _a.testsuite) === null || _b === void 0 ? void 0 : _b.map(ts => getSuiteSummary(ts)).join('\n');
|
const suites = (_b = (_a = junit.testsuites) === null || _a === void 0 ? void 0 : _a.testsuite) === null || _b === void 0 ? void 0 : _b.map((ts, i) => getSuiteSummary(ts, i)).join('\n');
|
||||||
const suitesSection = `## Test Suites\n\n${suites}`;
|
const suitesSection = `## Test Suites\n\n${suites}`;
|
||||||
return `${heading}\n${headingLine}\n${summary}\n${suitesSection}`;
|
return `${heading}\n${headingLine}\n${summary}\n${suitesSection}`;
|
||||||
}
|
}
|
||||||
function getSkippedCount(suites) {
|
function getSkippedCount(suites) {
|
||||||
return suites.testsuite.reduce((sum, suite) => sum + suite.$.skipped, 0);
|
return suites.testsuite.reduce((sum, suite) => sum + suite.$.skipped, 0);
|
||||||
}
|
}
|
||||||
function getSuiteSummary(suite) {
|
function getSuiteSummary(suite, index) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
const success = !(((_a = suite.$) === null || _a === void 0 ? void 0 : _a.failures) > 0 || ((_b = suite.$) === null || _b === void 0 ? void 0 : _b.errors) > 0);
|
const success = !(((_a = suite.$) === null || _a === void 0 ? void 0 : _a.failures) > 0 || ((_b = suite.$) === null || _b === void 0 ? void 0 : _b.errors) > 0);
|
||||||
const icon = success ? markdown_utils_1.Icon.success : markdown_utils_1.Icon.fail;
|
const icon = success ? markdown_utils_1.Icon.success : markdown_utils_1.Icon.fail;
|
||||||
|
|
@ -168,7 +164,10 @@ function getSuiteSummary(suite) {
|
||||||
return `${header}${tests}\n`;
|
return `${header}${tests}\n`;
|
||||||
})
|
})
|
||||||
.join('\n');
|
.join('\n');
|
||||||
return `### ${suite.$.name} ${icon}\n\n${content}`;
|
const tsName = suite.$.name;
|
||||||
|
const tsSlug = makeSuiteSlug(index, tsName);
|
||||||
|
const tsNameLink = `<a id="${tsSlug.id}" href="${tsSlug.link}">${tsName}</a>`;
|
||||||
|
return `### ${tsNameLink} ${icon}\n\n${content}`;
|
||||||
}
|
}
|
||||||
function getTestCaseIcon(test) {
|
function getTestCaseIcon(test) {
|
||||||
if (test.failure)
|
if (test.failure)
|
||||||
|
|
@ -187,6 +186,10 @@ function getTestCaseDetails(test) {
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
function makeSuiteSlug(index, name) {
|
||||||
|
// use "ts-$index-" as prefix to avoid slug conflicts after escaping the paths
|
||||||
|
return slugger_1.slug(`ts-${index}-${name}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
@ -328,6 +331,31 @@ function tableEscape(content) {
|
||||||
exports.tableEscape = tableEscape;
|
exports.tableEscape = tableEscape;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 3328:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.slug = void 0;
|
||||||
|
// Returns HTML element id and href link usable as manual anchor links
|
||||||
|
// This is needed because Github in check run summary doesn't automatically
|
||||||
|
// create links out of headings as it normally does for other markdown content
|
||||||
|
function slug(name) {
|
||||||
|
const slugId = name
|
||||||
|
.trim()
|
||||||
|
.replace(/_/g, '')
|
||||||
|
.replace(/[./\\]/g, '-')
|
||||||
|
.replace(/[^\w-]/g, '');
|
||||||
|
const id = `user-content-${slugId}`;
|
||||||
|
const link = `#${slugId}`;
|
||||||
|
return { id, link };
|
||||||
|
}
|
||||||
|
exports.slug = slug;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 8653:
|
/***/ 8653:
|
||||||
|
|
@ -4132,79 +4160,6 @@ class Deprecation extends Error {
|
||||||
exports.Deprecation = Deprecation;
|
exports.Deprecation = Deprecation;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 237:
|
|
||||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
||||||
|
|
||||||
var emoji = __webpack_require__(5464)
|
|
||||||
|
|
||||||
module.exports = BananaSlug
|
|
||||||
|
|
||||||
var own = Object.hasOwnProperty
|
|
||||||
var whitespace = /\s/g
|
|
||||||
var specials = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~’]/g
|
|
||||||
|
|
||||||
function BananaSlug () {
|
|
||||||
var self = this
|
|
||||||
|
|
||||||
if (!(self instanceof BananaSlug)) return new BananaSlug()
|
|
||||||
|
|
||||||
self.reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a unique slug.
|
|
||||||
* @param {string} value String of text to slugify
|
|
||||||
* @param {boolean} [false] Keep the current case, otherwise make all lowercase
|
|
||||||
* @return {string} A unique slug string
|
|
||||||
*/
|
|
||||||
BananaSlug.prototype.slug = function (value, maintainCase) {
|
|
||||||
var self = this
|
|
||||||
var slug = slugger(value, maintainCase === true)
|
|
||||||
var originalSlug = slug
|
|
||||||
|
|
||||||
while (own.call(self.occurrences, slug)) {
|
|
||||||
self.occurrences[originalSlug]++
|
|
||||||
slug = originalSlug + '-' + self.occurrences[originalSlug]
|
|
||||||
}
|
|
||||||
|
|
||||||
self.occurrences[slug] = 0
|
|
||||||
|
|
||||||
return slug
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset - Forget all previous slugs
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
BananaSlug.prototype.reset = function () {
|
|
||||||
this.occurrences = Object.create(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
function slugger (string, maintainCase) {
|
|
||||||
if (typeof string !== 'string') return ''
|
|
||||||
if (!maintainCase) string = string.toLowerCase()
|
|
||||||
|
|
||||||
return string.trim()
|
|
||||||
.replace(specials, '')
|
|
||||||
.replace(emoji(), '')
|
|
||||||
.replace(whitespace, '-')
|
|
||||||
}
|
|
||||||
|
|
||||||
BananaSlug.slug = slugger
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 5464:
|
|
||||||
/***/ ((module) => {
|
|
||||||
|
|
||||||
module.exports = function() {
|
|
||||||
return /[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2694\u2696\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD79\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED0\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3]|\uD83E[\uDD10-\uDD18\uDD80-\uDD84\uDDC0]|\uD83C\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uD83C\uDDFE\uD83C[\uDDEA\uDDF9]|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDFC\uD83C[\uDDEB\uDDF8]|\uD83C\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uD83C\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF8\uDDFE\uDDFF]|\uD83C\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uD83C\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uD83C\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uD83C\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uD83C\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uD83C\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uD83C\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uD83C\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uD83C\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uD83C\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uD83C\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uD83C\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uD83C\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uD83C\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uD83C\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uD83C\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|[#\*0-9]\u20E3/g;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 467:
|
/***/ 467:
|
||||||
|
|
|
||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
33
dist/licenses.txt
generated
vendored
33
dist/licenses.txt
generated
vendored
|
|
@ -444,39 +444,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
emoji-regex
|
|
||||||
MIT
|
|
||||||
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
github-slugger
|
|
||||||
ISC
|
|
||||||
Copyright (c) 2015, Dan Flettre <fletd01@yahoo.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
is-plain-object
|
is-plain-object
|
||||||
MIT
|
MIT
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
|
||||||
15
package-lock.json
generated
15
package-lock.json
generated
|
|
@ -4950,21 +4950,6 @@
|
||||||
"assert-plus": "^1.0.0"
|
"assert-plus": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"github-slugger": {
|
|
||||||
"version": "1.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.3.0.tgz",
|
|
||||||
"integrity": "sha512-gwJScWVNhFYSRDvURk/8yhcFBee6aFjye2a7Lhb2bUyRulpIoek9p0I9Kt7PT67d/nUlZbFu8L9RLiA0woQN8Q==",
|
|
||||||
"requires": {
|
|
||||||
"emoji-regex": ">=6.0.0 <=6.1.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"emoji-regex": {
|
|
||||||
"version": "6.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz",
|
|
||||||
"integrity": "sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"glob": {
|
"glob": {
|
||||||
"version": "7.1.6",
|
"version": "7.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^4.0.0",
|
||||||
"github-slugger": "^1.3.0",
|
|
||||||
"xml2js": "^0.4.23"
|
"xml2js": "^0.4.23"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import {TestResult} from '../test-parser'
|
import {TestResult} from '../test-parser'
|
||||||
import {parseStringPromise} from 'xml2js'
|
import {parseStringPromise} from 'xml2js'
|
||||||
import GithubSlugger from 'github-slugger'
|
|
||||||
|
|
||||||
import {JunitReport, TestCase, TestSuite, TestSuites} from './jest-junit-types'
|
import {JunitReport, TestCase, TestSuite, TestSuites} from './jest-junit-types'
|
||||||
import {Align, Icon, link, table, exceptionCell} from '../../utils/markdown-utils'
|
import {Align, Icon, link, table, exceptionCell} from '../../utils/markdown-utils'
|
||||||
|
import {slug} from '../../utils/slugger'
|
||||||
import {parseAttribute} from '../../utils/xml-utils'
|
import {parseAttribute} from '../../utils/xml-utils'
|
||||||
|
|
||||||
export async function parseJestJunit(content: string): Promise<TestResult> {
|
export async function parseJestJunit(content: string): Promise<TestResult> {
|
||||||
|
|
@ -11,20 +11,18 @@ export async function parseJestJunit(content: string): Promise<TestResult> {
|
||||||
attrValueProcessors: [parseAttribute]
|
attrValueProcessors: [parseAttribute]
|
||||||
})) as JunitReport
|
})) as JunitReport
|
||||||
const testsuites = junit.testsuites
|
const testsuites = junit.testsuites
|
||||||
|
|
||||||
const slugger = new GithubSlugger()
|
|
||||||
const success = !(testsuites.$?.failures > 0 || testsuites.$?.errors > 0)
|
const success = !(testsuites.$?.failures > 0 || testsuites.$?.errors > 0)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success,
|
success,
|
||||||
output: {
|
output: {
|
||||||
title: junit.testsuites.$.name,
|
title: junit.testsuites.$.name,
|
||||||
summary: getSummary(success, junit, slugger)
|
summary: getSummary(success, junit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSummary(success: boolean, junit: JunitReport, slugger: GithubSlugger): string {
|
function getSummary(success: boolean, junit: JunitReport): string {
|
||||||
const stats = junit.testsuites.$
|
const stats = junit.testsuites.$
|
||||||
|
|
||||||
const icon = success ? Icon.success : Icon.fail
|
const icon = success ? Icon.success : Icon.fail
|
||||||
|
|
@ -37,16 +35,16 @@ function getSummary(success: boolean, junit: JunitReport, slugger: GithubSlugger
|
||||||
const heading = `# ${stats.name} ${icon}`
|
const heading = `# ${stats.name} ${icon}`
|
||||||
const headingLine = `**${stats.tests}** tests were completed in **${time}** with **${passed}** passed, **${skipped}** skipped and **${failed}** failed.`
|
const headingLine = `**${stats.tests}** tests were completed in **${time}** with **${passed}** passed, **${skipped}** skipped and **${failed}** failed.`
|
||||||
|
|
||||||
const suitesSummary = junit.testsuites.testsuite.map(ts => {
|
const suitesSummary = junit.testsuites.testsuite.map((ts, i) => {
|
||||||
const skip = ts.$.skipped
|
const skip = ts.$.skipped
|
||||||
const fail = ts.$.errors + ts.$.failures
|
const fail = ts.$.errors + ts.$.failures
|
||||||
const pass = ts.$.tests - fail - skip
|
const pass = ts.$.tests - fail - skip
|
||||||
const tm = `${ts.$.time.toFixed(3)}s`
|
const tm = `${ts.$.time.toFixed(3)}s`
|
||||||
const result = success ? Icon.success : Icon.fail
|
const result = success ? Icon.success : Icon.fail
|
||||||
const slug = slugger.slug(`${ts.$.name} ${result}`).replace(/_/g, '')
|
const tsName = ts.$.name
|
||||||
const tsAddr = `#${slug}`
|
const tsAddr = makeSuiteSlug(i, tsName).link
|
||||||
const name = link(ts.$.name, tsAddr)
|
const tsNameLink = link(tsName, tsAddr)
|
||||||
return [result, name, ts.$.tests, tm, pass, fail, skip]
|
return [result, tsNameLink, ts.$.tests, tm, pass, fail, skip]
|
||||||
})
|
})
|
||||||
|
|
||||||
const summary = table(
|
const summary = table(
|
||||||
|
|
@ -55,7 +53,7 @@ function getSummary(success: boolean, junit: JunitReport, slugger: GithubSlugger
|
||||||
...suitesSummary
|
...suitesSummary
|
||||||
)
|
)
|
||||||
|
|
||||||
const suites = junit.testsuites?.testsuite?.map(ts => getSuiteSummary(ts)).join('\n')
|
const suites = junit.testsuites?.testsuite?.map((ts, i) => getSuiteSummary(ts, i)).join('\n')
|
||||||
const suitesSection = `## Test Suites\n\n${suites}`
|
const suitesSection = `## Test Suites\n\n${suites}`
|
||||||
|
|
||||||
return `${heading}\n${headingLine}\n${summary}\n${suitesSection}`
|
return `${heading}\n${headingLine}\n${summary}\n${suitesSection}`
|
||||||
|
|
@ -65,7 +63,7 @@ function getSkippedCount(suites: TestSuites): number {
|
||||||
return suites.testsuite.reduce((sum, suite) => sum + suite.$.skipped, 0)
|
return suites.testsuite.reduce((sum, suite) => sum + suite.$.skipped, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSuiteSummary(suite: TestSuite): string {
|
function getSuiteSummary(suite: TestSuite, index: number): string {
|
||||||
const success = !(suite.$?.failures > 0 || suite.$?.errors > 0)
|
const success = !(suite.$?.failures > 0 || suite.$?.errors > 0)
|
||||||
const icon = success ? Icon.success : Icon.fail
|
const icon = success ? Icon.success : Icon.fail
|
||||||
|
|
||||||
|
|
@ -98,7 +96,10 @@ function getSuiteSummary(suite: TestSuite): string {
|
||||||
})
|
})
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
return `### ${suite.$.name} ${icon}\n\n${content}`
|
const tsName = suite.$.name
|
||||||
|
const tsSlug = makeSuiteSlug(index, tsName)
|
||||||
|
const tsNameLink = `<a id="${tsSlug.id}" href="${tsSlug.link}">${tsName}</a>`
|
||||||
|
return `### ${tsNameLink} ${icon}\n\n${content}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTestCaseIcon(test: TestCase): string {
|
function getTestCaseIcon(test: TestCase): string {
|
||||||
|
|
@ -119,3 +120,8 @@ function getTestCaseDetails(test: TestCase): string {
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeSuiteSlug(index: number, name: string): {id: string; link: string} {
|
||||||
|
// use "ts-$index-" as prefix to avoid slug conflicts after escaping the paths
|
||||||
|
return slug(`ts-${index}-${name}`)
|
||||||
|
}
|
||||||
|
|
|
||||||
14
src/utils/slugger.ts
Normal file
14
src/utils/slugger.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Returns HTML element id and href link usable as manual anchor links
|
||||||
|
// This is needed because Github in check run summary doesn't automatically
|
||||||
|
// create links out of headings as it normally does for other markdown content
|
||||||
|
export function slug(name: string): {id: string; link: string} {
|
||||||
|
const slugId = name
|
||||||
|
.trim()
|
||||||
|
.replace(/_/g, '')
|
||||||
|
.replace(/[./\\]/g, '-')
|
||||||
|
.replace(/[^\w-]/g, '')
|
||||||
|
|
||||||
|
const id = `user-content-${slugId}`
|
||||||
|
const link = `#${slugId}`
|
||||||
|
return {id, link}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue