Skip to content

Commit a294a61

Browse files
authored
Merge pull request #1483 from mikepenz/fix/1471
Allow `includePassed` to work independently of `includePassed`
2 parents a67ac83 + aec5f48 commit a294a61

File tree

4 files changed

+132
-7
lines changed

4 files changed

+132
-7
lines changed

__tests__/table.test.ts

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,127 @@ describe('buildSummaryTables', () => {
216216
expect(flakyTable).toStrictEqual(FLAKY_TABLE)
217217
})
218218

219+
it('should show skipped tests when includeSkipped=true but includePassed=false', async () => {
220+
// This tests the key use case: showing only failed and skipped tests, without passed tests
221+
const testResult = await parseTestReports(
222+
'checkName',
223+
'summary',
224+
'test_results/tests/utils/target/surefire-reports/TEST-action.surefire.report.calc.StringUtilsTest.xml',
225+
'*',
226+
true, // Parse all tests
227+
true,
228+
true,
229+
[],
230+
undefined,
231+
'/'
232+
)
233+
234+
// Build with includePassed=false but includeSkipped=true
235+
const [, detailTable] = buildSummaryTables(
236+
[testResult],
237+
false, // includePassed - don't show passed tests
238+
true, // includeSkipped - but DO show skipped tests
239+
true, // detailedSummary
240+
false, // flakySummary
241+
false, // verboseSummary
242+
false // skipSuccessSummary
243+
)
244+
245+
const flatResults = detailTable.flat()
246+
247+
// Should include skipped tests
248+
const hasSkippedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('⚠️ skipped'))
249+
expect(hasSkippedTests).toBe(true)
250+
251+
// Should include failed tests
252+
const hasFailedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('❌ failure'))
253+
expect(hasFailedTests).toBe(true)
254+
255+
// Should NOT include passed tests
256+
const hasPassedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('✅ passed'))
257+
expect(hasPassedTests).toBe(false)
258+
})
259+
260+
it('should hide both passed and skipped when both include flags are false', async () => {
261+
const testResult = await parseTestReports(
262+
'checkName',
263+
'summary',
264+
'test_results/tests/utils/target/surefire-reports/TEST-action.surefire.report.calc.StringUtilsTest.xml',
265+
'*',
266+
true, // Parse all tests
267+
true,
268+
true,
269+
[],
270+
undefined,
271+
'/'
272+
)
273+
274+
// Build with both includePassed=false and includeSkipped=false
275+
const [, detailTable] = buildSummaryTables(
276+
[testResult],
277+
false, // includePassed - don't show passed tests
278+
false, // includeSkipped - don't show skipped tests either
279+
true, // detailedSummary
280+
false, // flakySummary
281+
false, // verboseSummary
282+
false // skipSuccessSummary
283+
)
284+
285+
const flatResults = detailTable.flat()
286+
287+
// Should NOT include skipped tests
288+
const hasSkippedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('⚠️ skipped'))
289+
expect(hasSkippedTests).toBe(false)
290+
291+
// Should include failed tests
292+
const hasFailedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('❌ failure'))
293+
expect(hasFailedTests).toBe(true)
294+
295+
// Should NOT include passed tests
296+
const hasPassedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('✅ passed'))
297+
expect(hasPassedTests).toBe(false)
298+
})
299+
300+
it('should show both passed and skipped when both include flags are true', async () => {
301+
const testResult = await parseTestReports(
302+
'checkName',
303+
'summary',
304+
'test_results/tests/utils/target/surefire-reports/TEST-action.surefire.report.calc.StringUtilsTest.xml',
305+
'*',
306+
true, // Parse all tests
307+
true,
308+
true,
309+
[],
310+
undefined,
311+
'/'
312+
)
313+
314+
// Build with both includePassed=true and includeSkipped=true
315+
const [, detailTable] = buildSummaryTables(
316+
[testResult],
317+
true, // includePassed - show passed tests
318+
true, // includeSkipped - show skipped tests
319+
true, // detailedSummary
320+
false, // flakySummary
321+
false, // verboseSummary
322+
false // skipSuccessSummary
323+
)
324+
325+
const flatResults = detailTable.flat()
326+
327+
// Should include skipped tests
328+
const hasSkippedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('⚠️ skipped'))
329+
expect(hasSkippedTests).toBe(true)
330+
331+
// Should include failed tests
332+
const hasFailedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('❌ failure'))
333+
expect(hasFailedTests).toBe(true)
334+
335+
// Should include passed tests
336+
const hasPassedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('✅ passed'))
337+
expect(hasPassedTests).toBe(true)
338+
})
339+
219340
it('should include flaky tests in summary even when includePassed is false', async () => {
220341
const testResult = await parseTestReports(
221342
'checkName',

dist/index.js

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/table.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function buildSummaryTables(
9393

9494
const annotations = testResult.globalAnnotations.filter(
9595
annotation =>
96-
(includePassed || annotation.annotation_level !== 'notice' || annotation.retries > 0) &&
96+
(includePassed || annotation.status !== 'success' || annotation.retries > 0) &&
9797
(includeSkipped || annotation.status !== 'skipped')
9898
)
9999

@@ -112,7 +112,8 @@ export function buildSummaryTables(
112112
if (!groupSuite) {
113113
for (const annotation of annotations) {
114114
// Skip passed tests (including flaky ones) in details table when includePassed is false
115-
if (!includePassed && annotation.annotation_level === 'notice') {
115+
// Note: skipped tests have status='skipped' and are handled separately by includeSkipped
116+
if (!includePassed && annotation.status === 'success') {
116117
continue
117118
}
118119
const detailsRow = [
@@ -174,9 +175,10 @@ function appendDetailsTable(
174175
): void {
175176
const colspan = includeTimeInSummary ? '3' : '2'
176177
// For details table, don't include passed tests when includePassed is false (even if flaky)
178+
// Note: skipped tests have status='skipped' and are handled separately by includeSkipped
177179
const annotations = testResult.annotations.filter(
178180
annotation =>
179-
(includePassed || annotation.annotation_level !== 'notice') &&
181+
(includePassed || annotation.status !== 'success') &&
180182
(includeSkipped || annotation.status !== 'skipped')
181183
)
182184
if (annotations.length > 0) {

0 commit comments

Comments
 (0)