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

Add sort-suites report coverage

This commit is contained in:
Jozef Izso 2026-04-25 12:15:53 +02:00
parent 0e1fe1690f
commit a1f5af1564
Failed to extract signature

View file

@ -1,4 +1,5 @@
import {getBadge, DEFAULT_OPTIONS, ReportOptions} from '../../src/report/get-report.js' import {DEFAULT_OPTIONS, getBadge, getReport, ReportOptions} from '../../src/report/get-report.js'
import {TestCaseResult, TestGroupResult, TestRunResult, TestSuiteResult} from '../../src/test-results.js'
describe('getBadge', () => { describe('getBadge', () => {
describe('URI encoding with special characters', () => { describe('URI encoding with special characters', () => {
@ -131,3 +132,28 @@ describe('getBadge', () => {
}) })
}) })
}) })
describe('getReport', () => {
it('sorts suites by descending time when configured', () => {
const results = [
new TestRunResult('report.xml', [
createSuite('unit', 10),
createSuite('integration', 30),
createSuite('smoke', 20)
])
]
const report = getReport(results, {
...DEFAULT_OPTIONS,
sortSuites: 'time-desc',
listTests: 'none'
})
expect(report.indexOf('integration')).toBeLessThan(report.indexOf('smoke'))
expect(report.indexOf('smoke')).toBeLessThan(report.indexOf('unit'))
})
})
function createSuite(name: string, time: number): TestSuiteResult {
return new TestSuiteResult(name, [new TestGroupResult(name, [new TestCaseResult(`${name}-test`, 'success', time)])])
}