1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-05-06 10:37:36 +02:00

Resolve list-files conflicts on current main

This commit is contained in:
Jozef Izso 2026-04-25 12:13:19 +02:00
parent ba6f1d11e2
commit 45c8d46681
Failed to extract signature
4 changed files with 37 additions and 11 deletions

View file

@ -1,5 +1,5 @@
import {DEFAULT_OPTIONS, getBadge, getReport, ReportOptions} from '../../src/report/get-report.js'
import {TestCaseResult, TestGroupResult, TestRunResult, TestSuiteResult} from '../../src/test-results'
import {TestCaseResult, TestGroupResult, TestRunResult, TestSuiteResult} from '../../src/test-results.js'
describe('getBadge', () => {
describe('URI encoding with special characters', () => {
@ -141,10 +141,12 @@ describe('getReport', () => {
tests.push(new TestCaseResult(`passed-test-${i}`, 'success', 100))
}
for (let i = 0; i < failed; i++) {
tests.push(new TestCaseResult(`failed-test-${i}`, 'failed', 100, {
details: 'Test failed',
message: 'Assertion error'
}))
tests.push(
new TestCaseResult(`failed-test-${i}`, 'failed', 100, {
details: 'Test failed',
message: 'Assertion error'
})
)
}
for (let i = 0; i < skipped; i++) {
tests.push(new TestCaseResult(`skipped-test-${i}`, 'skipped', 0))

22
dist/index.js generated vendored
View file

@ -56954,6 +56954,7 @@ const DEFAULT_OPTIONS = {
listSuites: 'all',
listTests: 'all',
slugPrefix: '',
listFiles: 'all',
baseUrl: '',
onlySummary: false,
useActionsSummary: true,
@ -57074,8 +57075,14 @@ function getTestRunsReport(testRuns, options) {
sections.push(`<details><summary>Expand for details</summary>`);
sections.push(` `);
}
if (testRuns.length > 0 || options.onlySummary) {
const tableData = testRuns
// Filter test runs based on list-files option
const filteredTestRuns = options.listFiles === 'failed'
? testRuns.filter(tr => tr.result === 'failed')
: options.listFiles === 'none'
? []
: testRuns;
if (filteredTestRuns.length > 0 || options.onlySummary) {
const tableData = filteredTestRuns
.map((tr, originalIndex) => ({ tr, originalIndex }))
.filter(({ tr }) => tr.passed > 0 || tr.failed > 0 || tr.skipped > 0)
.map(({ tr, originalIndex }) => {
@ -57092,7 +57099,7 @@ function getTestRunsReport(testRuns, options) {
sections.push(resultsTable);
}
if (options.onlySummary === false) {
const suitesReports = testRuns.map((tr, i) => getSuitesReport(tr, i, options)).flat();
const suitesReports = filteredTestRuns.map((tr, i) => getSuitesReport(tr, i, options)).flat();
sections.push(...suitesReports);
}
if (shouldCollapse) {
@ -58949,6 +58956,7 @@ class TestReporter {
reporter = getInput('reporter', { required: true });
listSuites = getInput('list-suites', { required: true });
listTests = getInput('list-tests', { required: true });
listFiles = getInput('list-files', { required: true });
maxAnnotations = parseInt(getInput('max-annotations', { required: true }));
failOnError = getInput('fail-on-error', { required: true }) === 'true';
failOnEmpty = getInput('fail-on-empty', { required: true }) === 'true';
@ -58972,6 +58980,10 @@ class TestReporter {
setFailed(`Input parameter 'list-tests' has invalid value`);
return;
}
if (this.listFiles !== 'all' && this.listFiles !== 'failed' && this.listFiles !== 'none') {
setFailed(`Input parameter 'list-files' has invalid value`);
return;
}
if (this.collapsed !== 'auto' && this.collapsed !== 'always' && this.collapsed !== 'never') {
setFailed(`Input parameter 'collapsed' has invalid value`);
return;
@ -59056,7 +59068,7 @@ class TestReporter {
throw error;
}
}
const { listSuites, listTests, slugPrefix, onlySummary, useActionsSummary, badgeTitle, reportTitle, collapsed } = this;
const { listSuites, listTests, slugPrefix, listFiles, onlySummary, useActionsSummary, badgeTitle, reportTitle, collapsed } = this;
const passed = results.reduce((sum, tr) => sum + tr.passed, 0);
const failed = results.reduce((sum, tr) => sum + tr.failed, 0);
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0);
@ -59067,6 +59079,7 @@ class TestReporter {
listSuites,
listTests,
slugPrefix,
listFiles,
baseUrl,
onlySummary,
useActionsSummary,
@ -59096,6 +59109,7 @@ class TestReporter {
listSuites,
listTests,
slugPrefix,
listFiles,
baseUrl,
onlySummary,
useActionsSummary,

View file

@ -183,7 +183,17 @@ class TestReporter {
}
}
const {listSuites, listTests, slugPrefix, listFiles, onlySummary, useActionsSummary, badgeTitle, reportTitle, collapsed} = this
const {
listSuites,
listTests,
slugPrefix,
listFiles,
onlySummary,
useActionsSummary,
badgeTitle,
reportTitle,
collapsed
} = this
const passed = results.reduce((sum, tr) => sum + tr.passed, 0)
const failed = results.reduce((sum, tr) => sum + tr.failed, 0)

View file

@ -11,7 +11,7 @@ const MAX_ACTIONS_SUMMARY_LENGTH = 1048576
export interface ReportOptions {
listSuites: 'all' | 'failed' | 'none'
listTests: 'all' | 'failed' | 'none'
slugPrefix: string;
slugPrefix: string
listFiles: 'all' | 'failed' | 'none'
baseUrl: string
onlySummary: boolean