report failed tests to slack

This commit is contained in:
A.J. Kaptijn 2024-03-14 17:32:48 +01:00
parent dd70238216
commit 7cb3970161
4 changed files with 39 additions and 6 deletions

View file

@ -328,6 +328,22 @@ class TestReporter {
text: `:red_circle: ${tr.failed} in <${resp.data.html_url}#r${runIndex}|${runName}>`
}
})
if (failed <= 10) {
tr.failedSuites.map(suite => {
suite.failedGroups.map(group => {
group.failedTests.map(test => {
req.blocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: `:red_circle: <${suite.link}|${test.name}>`
}
})
})
})
})
}
})
await webhook.send(req)

View file

@ -199,8 +199,8 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt
const tsTime = formatTime(s.time)
const tsName = s.name.startsWith(name) ? s.name.slice(name.length + 1) : s.name
const skipLink = options.listTests === 'none' || (options.listTests === 'failed' && s.result !== 'failed')
const tsAddr = options.baseUrl + makeSuiteSlug(runIndex, suiteIndex).link
const tsNameLink = skipLink ? tsName : link(tsName, tsAddr)
s.link = options.baseUrl + makeSuiteSlug(runIndex, suiteIndex).link
const tsNameLink = skipLink ? tsName : link(tsName, s.link)
const passed = s.passed > 0 ? `${s.passed}${Icon.success}` : ''
const failed = s.failed > 0 ? `${s.failed}${Icon.fail}` : ''
const skipped = s.skipped > 0 ? `${s.skipped}${Icon.skip}` : ''
@ -234,7 +234,7 @@ function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: numbe
const tsName = ts.name
const tsSlug = makeSuiteSlug(runIndex, suiteIndex)
const tsNameLink = `<a id="${tsSlug.id}" href="${options.baseUrl + tsSlug.link}">${tsName}</a>`
const tsNameLink = `<a id="${tsSlug.id}" href="${ts.link}">${tsName}</a>`
const icon = getResultIcon(ts.result)
sections.push(`### ${icon}\xa0${tsNameLink}`)

View file

@ -82,6 +82,8 @@ export class TestSuiteResult {
private totalTime?: number
) {}
link?: string
get tests(): number {
return this.groups.reduce((sum, g) => sum + g.tests.length, 0)
}