Remove 'Details' column from Test case report

Stack traces doesn't fit well into the table - there was not enough width for it.  Now the stack traces are included in annotations which looks much better
This commit is contained in:
Michal Dorner 2020-11-29 20:07:32 +01:00
parent 63b94a335a
commit bff3069f5c
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
5 changed files with 34 additions and 96 deletions

42
dist/index.js generated vendored
View file

@ -170,12 +170,11 @@ function getSuiteSummary(suite, index) {
const content = groups
.map(grp => {
const header = grp.describe !== '' ? `#### ${grp.describe}\n\n` : '';
const tests = markdown_utils_1.table(['Result', 'Test', 'Time', 'Details'], [markdown_utils_1.Align.Center, markdown_utils_1.Align.Left, markdown_utils_1.Align.Right, markdown_utils_1.Align.None], ...grp.tests.map(tc => {
const tests = markdown_utils_1.table(['Result', 'Test', 'Time'], [markdown_utils_1.Align.Center, markdown_utils_1.Align.Left, markdown_utils_1.Align.Right], ...grp.tests.map(tc => {
const name = tc.$.name;
const time = `${Math.round(tc.$.time * 1000)}ms`;
const result = getTestCaseIcon(tc);
const ex = getTestCaseDetails(tc);
return [result, name, time, ex];
return [result, name, time];
}));
return `${header}${tests}\n`;
})
@ -192,16 +191,6 @@ function getTestCaseIcon(test) {
return markdown_utils_1.Icon.skip;
return markdown_utils_1.Icon.success;
}
function getTestCaseDetails(test) {
if (test.skipped !== undefined) {
return 'Skipped';
}
if (test.failure !== undefined) {
const failure = test.failure.join('\n');
return markdown_utils_1.exceptionCell(failure);
}
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}`);
@ -224,7 +213,7 @@ function getAnnotations(junit, workDir, trackedFiles) {
end_line: src.line,
path: src.file,
message: ex,
title: 'Exception was thrown here'
title: `Test Failed: ${tc.$.name}`
});
}
}
@ -437,7 +426,7 @@ exports.getCheckRunSha = getCheckRunSha;
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tableEscape = exports.exceptionCell = exports.table = exports.link = exports.details = exports.Icon = exports.Align = void 0;
exports.tableEscape = exports.table = exports.link = exports.details = exports.Icon = exports.Align = void 0;
var Align;
(function (Align) {
Align["Left"] = ":---";
@ -459,31 +448,14 @@ function link(title, address) {
}
exports.link = link;
function table(headers, align, ...rows) {
const headerRow = `| ${headers.join(' | ')} |`;
const headerRow = `| ${headers.map(tableEscape).join(' | ')} |`;
const alignRow = `| ${align.join(' | ')} |`;
const contentRows = rows.map(row => `| ${row.join(' | ')} |`).join('\n');
const contentRows = rows.map(row => `| ${row.map(tableEscape).join(' | ')} |`).join('\n');
return [headerRow, alignRow, contentRows].join('\n');
}
exports.table = table;
function exceptionCell(ex) {
var _a;
const lines = ex.split(/\r?\n/);
if (lines.length === 0) {
return '';
}
const summary = tableEscape(((_a = lines.shift()) === null || _a === void 0 ? void 0 : _a.trim()) || '');
const emptyLine = /^\s*$/;
const firstNonEmptyLine = lines.findIndex(l => !emptyLine.test(l));
if (firstNonEmptyLine === -1) {
return summary;
}
const contentLines = firstNonEmptyLine > 0 ? lines.slice(firstNonEmptyLine) : lines;
const content = '<pre>' + tableEscape(contentLines.join('<br>')) + '</pre>';
return details(summary, content);
}
exports.exceptionCell = exceptionCell;
function tableEscape(content) {
return content.replace('|', '\\|');
return content.toString().replace('|', '\\|');
}
exports.tableEscape = tableEscape;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long