mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Support none for list-suites
This commit is contained in:
parent
49667db475
commit
bd77050543
6 changed files with 63 additions and 57 deletions
|
|
@ -141,6 +141,7 @@ jobs:
|
||||||
# Limits which test suites are listed:
|
# Limits which test suites are listed:
|
||||||
# all
|
# all
|
||||||
# failed
|
# failed
|
||||||
|
# none
|
||||||
list-suites: 'all'
|
list-suites: 'all'
|
||||||
|
|
||||||
# Limits which test cases are listed:
|
# Limits which test cases are listed:
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ inputs:
|
||||||
Limits which test suites are listed. Supported options:
|
Limits which test suites are listed. Supported options:
|
||||||
- all
|
- all
|
||||||
- only-failed
|
- only-failed
|
||||||
|
- none
|
||||||
required: true
|
required: true
|
||||||
default: 'all'
|
default: 'all'
|
||||||
list-tests:
|
list-tests:
|
||||||
|
|
|
||||||
48
dist/index.js
generated
vendored
48
dist/index.js
generated
vendored
|
|
@ -298,7 +298,7 @@ class TestReporter {
|
||||||
this.token = core.getInput('token', { required: true });
|
this.token = core.getInput('token', { required: true });
|
||||||
this.context = (0, github_utils_1.getCheckRunContext)();
|
this.context = (0, github_utils_1.getCheckRunContext)();
|
||||||
this.octokit = github.getOctokit(this.token);
|
this.octokit = github.getOctokit(this.token);
|
||||||
if (this.listSuites !== 'all' && this.listSuites !== 'failed') {
|
if (this.listSuites !== 'all' && this.listSuites !== 'failed' && this.listSuites !== 'none') {
|
||||||
core.setFailed(`Input parameter 'list-suites' has invalid value`);
|
core.setFailed(`Input parameter 'list-suites' has invalid value`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1524,29 +1524,31 @@ function getTestRunsReport(testRuns, options) {
|
||||||
}
|
}
|
||||||
function getSuitesReport(tr, runIndex, options) {
|
function getSuitesReport(tr, runIndex, options) {
|
||||||
const sections = [];
|
const sections = [];
|
||||||
const trSlug = makeRunSlug(runIndex);
|
|
||||||
const nameLink = `<a id="${trSlug.id}" href="${options.baseUrl + trSlug.link}">${tr.path}</a>`;
|
|
||||||
const icon = getResultIcon(tr.result);
|
|
||||||
sections.push(`## ${icon}\xa0${nameLink}`);
|
|
||||||
const time = (0, markdown_utils_1.formatTime)(tr.time);
|
|
||||||
const headingLine2 = tr.tests > 0
|
|
||||||
? `**${tr.tests}** tests were completed in **${time}** with **${tr.passed}** passed, **${tr.failed}** failed and **${tr.skipped}** skipped.`
|
|
||||||
: 'No tests found';
|
|
||||||
sections.push(headingLine2);
|
|
||||||
const suites = options.listSuites === 'failed' ? tr.failedSuites : tr.suites;
|
const suites = options.listSuites === 'failed' ? tr.failedSuites : tr.suites;
|
||||||
if (suites.length > 0) {
|
if (options.listSuites !== 'none') {
|
||||||
const suitesTable = (0, markdown_utils_1.table)(['Test suite', 'Passed', 'Failed', 'Skipped', 'Time'], [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], ...suites.map((s, suiteIndex) => {
|
const trSlug = makeRunSlug(runIndex);
|
||||||
const tsTime = (0, markdown_utils_1.formatTime)(s.time);
|
const nameLink = `<a id="${trSlug.id}" href="${options.baseUrl + trSlug.link}">${tr.path}</a>`;
|
||||||
const tsName = s.name;
|
const icon = getResultIcon(tr.result);
|
||||||
const skipLink = options.listTests === 'none' || (options.listTests === 'failed' && s.result !== 'failed');
|
sections.push(`## ${icon}\xa0${nameLink}`);
|
||||||
const tsAddr = options.baseUrl + makeSuiteSlug(runIndex, suiteIndex).link;
|
const time = (0, markdown_utils_1.formatTime)(tr.time);
|
||||||
const tsNameLink = skipLink ? tsName : (0, markdown_utils_1.link)(tsName, tsAddr);
|
const headingLine2 = tr.tests > 0
|
||||||
const passed = s.passed > 0 ? `${s.passed}${markdown_utils_1.Icon.success}` : '';
|
? `**${tr.tests}** tests were completed in **${time}** with **${tr.passed}** passed, **${tr.failed}** failed and **${tr.skipped}** skipped.`
|
||||||
const failed = s.failed > 0 ? `${s.failed}${markdown_utils_1.Icon.fail}` : '';
|
: 'No tests found';
|
||||||
const skipped = s.skipped > 0 ? `${s.skipped}${markdown_utils_1.Icon.skip}` : '';
|
sections.push(headingLine2);
|
||||||
return [tsNameLink, passed, failed, skipped, tsTime];
|
if (suites.length > 0) {
|
||||||
}));
|
const suitesTable = (0, markdown_utils_1.table)(['Test suite', 'Passed', 'Failed', 'Skipped', 'Time'], [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], ...suites.map((s, suiteIndex) => {
|
||||||
sections.push(suitesTable);
|
const tsTime = (0, markdown_utils_1.formatTime)(s.time);
|
||||||
|
const tsName = 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 : (0, markdown_utils_1.link)(tsName, tsAddr);
|
||||||
|
const passed = s.passed > 0 ? `${s.passed}${markdown_utils_1.Icon.success}` : '';
|
||||||
|
const failed = s.failed > 0 ? `${s.failed}${markdown_utils_1.Icon.fail}` : '';
|
||||||
|
const skipped = s.skipped > 0 ? `${s.skipped}${markdown_utils_1.Icon.skip}` : '';
|
||||||
|
return [tsNameLink, passed, failed, skipped, tsTime];
|
||||||
|
}));
|
||||||
|
sections.push(suitesTable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (options.listTests !== 'none') {
|
if (options.listTests !== 'none') {
|
||||||
const tests = suites.map((ts, suiteIndex) => getTestsReport(ts, runIndex, suiteIndex, options)).flat();
|
const tests = suites.map((ts, suiteIndex) => getTestsReport(ts, runIndex, suiteIndex, options)).flat();
|
||||||
|
|
|
||||||
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
|
|
@ -35,7 +35,7 @@ class TestReporter {
|
||||||
readonly path = core.getInput('path', {required: true})
|
readonly path = core.getInput('path', {required: true})
|
||||||
readonly pathReplaceBackslashes = core.getInput('path-replace-backslashes', {required: false}) === 'true'
|
readonly pathReplaceBackslashes = core.getInput('path-replace-backslashes', {required: false}) === 'true'
|
||||||
readonly reporter = core.getInput('reporter', {required: true})
|
readonly reporter = core.getInput('reporter', {required: true})
|
||||||
readonly listSuites = core.getInput('list-suites', {required: true}) as 'all' | 'failed'
|
readonly listSuites = core.getInput('list-suites', {required: true}) as 'all' | 'failed' | 'none'
|
||||||
readonly listTests = core.getInput('list-tests', {required: true}) as 'all' | 'failed' | 'none'
|
readonly listTests = core.getInput('list-tests', {required: true}) as 'all' | 'failed' | 'none'
|
||||||
readonly maxAnnotations = parseInt(core.getInput('max-annotations', {required: true}))
|
readonly maxAnnotations = parseInt(core.getInput('max-annotations', {required: true}))
|
||||||
readonly failOnError = core.getInput('fail-on-error', {required: true}) === 'true'
|
readonly failOnError = core.getInput('fail-on-error', {required: true}) === 'true'
|
||||||
|
|
@ -49,7 +49,7 @@ class TestReporter {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.octokit = github.getOctokit(this.token)
|
this.octokit = github.getOctokit(this.token)
|
||||||
|
|
||||||
if (this.listSuites !== 'all' && this.listSuites !== 'failed') {
|
if (this.listSuites !== 'all' && this.listSuites !== 'failed' && this.listSuites !== 'none') {
|
||||||
core.setFailed(`Input parameter 'list-suites' has invalid value`)
|
core.setFailed(`Input parameter 'list-suites' has invalid value`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {slug} from '../utils/slugger'
|
||||||
const MAX_REPORT_LENGTH = 65535
|
const MAX_REPORT_LENGTH = 65535
|
||||||
|
|
||||||
export interface ReportOptions {
|
export interface ReportOptions {
|
||||||
listSuites: 'all' | 'failed'
|
listSuites: 'all' | 'failed' | 'none'
|
||||||
listTests: 'all' | 'failed' | 'none'
|
listTests: 'all' | 'failed' | 'none'
|
||||||
baseUrl: string
|
baseUrl: string
|
||||||
onlySummary: boolean
|
onlySummary: boolean
|
||||||
|
|
@ -166,37 +166,39 @@ function getTestRunsReport(testRuns: TestRunResult[], options: ReportOptions): s
|
||||||
|
|
||||||
function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOptions): string[] {
|
function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOptions): string[] {
|
||||||
const sections: string[] = []
|
const sections: string[] = []
|
||||||
|
|
||||||
const trSlug = makeRunSlug(runIndex)
|
|
||||||
const nameLink = `<a id="${trSlug.id}" href="${options.baseUrl + trSlug.link}">${tr.path}</a>`
|
|
||||||
const icon = getResultIcon(tr.result)
|
|
||||||
sections.push(`## ${icon}\xa0${nameLink}`)
|
|
||||||
|
|
||||||
const time = formatTime(tr.time)
|
|
||||||
const headingLine2 =
|
|
||||||
tr.tests > 0
|
|
||||||
? `**${tr.tests}** tests were completed in **${time}** with **${tr.passed}** passed, **${tr.failed}** failed and **${tr.skipped}** skipped.`
|
|
||||||
: 'No tests found'
|
|
||||||
sections.push(headingLine2)
|
|
||||||
|
|
||||||
const suites = options.listSuites === 'failed' ? tr.failedSuites : tr.suites
|
const suites = options.listSuites === 'failed' ? tr.failedSuites : tr.suites
|
||||||
if (suites.length > 0) {
|
|
||||||
const suitesTable = table(
|
if (options.listSuites !== 'none') {
|
||||||
['Test suite', 'Passed', 'Failed', 'Skipped', 'Time'],
|
const trSlug = makeRunSlug(runIndex)
|
||||||
[Align.Left, Align.Right, Align.Right, Align.Right, Align.Right],
|
const nameLink = `<a id="${trSlug.id}" href="${options.baseUrl + trSlug.link}">${tr.path}</a>`
|
||||||
...suites.map((s, suiteIndex) => {
|
const icon = getResultIcon(tr.result)
|
||||||
const tsTime = formatTime(s.time)
|
sections.push(`## ${icon}\xa0${nameLink}`)
|
||||||
const tsName = s.name
|
|
||||||
const skipLink = options.listTests === 'none' || (options.listTests === 'failed' && s.result !== 'failed')
|
const time = formatTime(tr.time)
|
||||||
const tsAddr = options.baseUrl + makeSuiteSlug(runIndex, suiteIndex).link
|
const headingLine2 =
|
||||||
const tsNameLink = skipLink ? tsName : link(tsName, tsAddr)
|
tr.tests > 0
|
||||||
const passed = s.passed > 0 ? `${s.passed}${Icon.success}` : ''
|
? `**${tr.tests}** tests were completed in **${time}** with **${tr.passed}** passed, **${tr.failed}** failed and **${tr.skipped}** skipped.`
|
||||||
const failed = s.failed > 0 ? `${s.failed}${Icon.fail}` : ''
|
: 'No tests found'
|
||||||
const skipped = s.skipped > 0 ? `${s.skipped}${Icon.skip}` : ''
|
sections.push(headingLine2)
|
||||||
return [tsNameLink, passed, failed, skipped, tsTime]
|
|
||||||
})
|
if (suites.length > 0) {
|
||||||
)
|
const suitesTable = table(
|
||||||
sections.push(suitesTable)
|
['Test suite', 'Passed', 'Failed', 'Skipped', 'Time'],
|
||||||
|
[Align.Left, Align.Right, Align.Right, Align.Right, Align.Right],
|
||||||
|
...suites.map((s, suiteIndex) => {
|
||||||
|
const tsTime = formatTime(s.time)
|
||||||
|
const tsName = 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)
|
||||||
|
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}` : ''
|
||||||
|
return [tsNameLink, passed, failed, skipped, tsTime]
|
||||||
|
})
|
||||||
|
)
|
||||||
|
sections.push(suitesTable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.listTests !== 'none') {
|
if (options.listTests !== 'none') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue