mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
wip
This commit is contained in:
parent
180bde26b2
commit
25189ba00b
2 changed files with 44 additions and 10 deletions
45
src/main.ts
45
src/main.ts
|
|
@ -213,14 +213,14 @@ class TestReporter {
|
||||||
const passed = results.reduce((sum, tr) => sum + tr.passed, 0)
|
const passed = results.reduce((sum, tr) => sum + tr.passed, 0)
|
||||||
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0)
|
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0)
|
||||||
const failed = results.reduce((sum, tr) => sum + tr.failed, 0)
|
const failed = results.reduce((sum, tr) => sum + tr.failed, 0)
|
||||||
await webhook.send({
|
|
||||||
|
const req = {
|
||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
type: 'header',
|
type: 'header',
|
||||||
text: {
|
text: {
|
||||||
type: 'plain_text',
|
type: 'plain_text',
|
||||||
text: 'Test results',
|
text: 'Test results'
|
||||||
emoji: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -250,15 +250,46 @@ class TestReporter {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'section',
|
type: 'divider'
|
||||||
text: {
|
|
||||||
type: 'mrkdwn',
|
|
||||||
text: `<${resp.data.html_url}|View report>`
|
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
results.map((tr, runIndex) => {
|
||||||
|
if (tr.failed === 0) return
|
||||||
|
const runName = tr.path.slice(0, tr.path.indexOf('/TestResults/'))
|
||||||
|
|
||||||
|
req.blocks.push({
|
||||||
|
type: 'section',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'mrkdwn',
|
||||||
|
text: `<${resp.data.html_url}#r${runIndex}|*${runName}*>`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'mrkdwn',
|
||||||
|
text: `:red_circle: ${tr.failed}`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
req.blocks.push(
|
||||||
|
{
|
||||||
|
type: 'divider'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'section',
|
||||||
|
text: {
|
||||||
|
type: 'mrkdwn',
|
||||||
|
text: `<${resp.data.html_url}|View full report>`
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
await webhook.send(req)
|
||||||
|
}
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,8 @@ function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): s
|
||||||
if (testRuns.length > 1 || options.onlySummary) {
|
if (testRuns.length > 1 || options.onlySummary) {
|
||||||
const tableData = testRuns.map((tr, runIndex) => {
|
const tableData = testRuns.map((tr, runIndex) => {
|
||||||
const time = formatTime(tr.time)
|
const time = formatTime(tr.time)
|
||||||
const name = tr.path
|
const folder = tr.path.indexOf('/TestResults/')
|
||||||
|
const name = folder > 0 ? tr.path.slice(0, folder) : tr.path
|
||||||
const addr = options.baseUrl + makeRunSlug(runIndex).link
|
const addr = options.baseUrl + makeRunSlug(runIndex).link
|
||||||
const nameLink = link(name, addr)
|
const nameLink = link(name, addr)
|
||||||
const passed = tr.passed > 0 ? `${tr.passed}${Icon.success}` : ''
|
const passed = tr.passed > 0 ? `${tr.passed}${Icon.success}` : ''
|
||||||
|
|
@ -166,7 +167,9 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt
|
||||||
const sections: string[] = []
|
const sections: string[] = []
|
||||||
|
|
||||||
const trSlug = makeRunSlug(runIndex)
|
const trSlug = makeRunSlug(runIndex)
|
||||||
const nameLink = `<a id="${trSlug.id}" href="${options.baseUrl + trSlug.link}">${tr.path}</a>`
|
const folder = tr.path.indexOf('/TestResults/')
|
||||||
|
const name = folder > 0 ? tr.path.slice(0, folder) : tr.path
|
||||||
|
const nameLink = `<a id="${trSlug.id}" href="${options.baseUrl + trSlug.link}">${name}</a>`
|
||||||
const icon = getResultIcon(tr.result)
|
const icon = getResultIcon(tr.result)
|
||||||
sections.push(`## ${icon}\xa0${nameLink}`)
|
sections.push(`## ${icon}\xa0${nameLink}`)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue