mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 14:27:10 +01:00
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:
parent
63b94a335a
commit
bff3069f5c
5 changed files with 34 additions and 96 deletions
|
|
@ -21,32 +21,12 @@ export function link(title: string, address: string): string {
|
|||
|
||||
type ToString = string | number | boolean | Date
|
||||
export function table(headers: ToString[], align: ToString[], ...rows: ToString[][]): string {
|
||||
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')
|
||||
}
|
||||
|
||||
export function exceptionCell(ex: string): string {
|
||||
const lines = ex.split(/\r?\n/)
|
||||
if (lines.length === 0) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const summary = tableEscape(lines.shift()?.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)
|
||||
}
|
||||
|
||||
export function tableEscape(content: string): string {
|
||||
return content.replace('|', '\\|')
|
||||
export function tableEscape(content: ToString): string {
|
||||
return content.toString().replace('|', '\\|')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue