List only failed tests

Fixes issue #142
This commit is contained in:
Siegfried Pammer 2022-03-06 19:00:25 +01:00 committed by Jozef Izso
parent a6b3e93884
commit 2312e637f3
Failed to extract signature
4 changed files with 187 additions and 1 deletions

View file

@ -3,7 +3,7 @@ import * as path from 'path'
import {DotnetTrxParser} from '../src/parsers/dotnet-trx/dotnet-trx-parser'
import {ParseOptions} from '../src/test-parser'
import {DEFAULT_OPTIONS, getReport} from '../src/report/get-report'
import {DEFAULT_OPTIONS, getReport, ReportOptions} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/path-utils'
describe('dotnet-trx tests', () => {
@ -60,6 +60,32 @@ describe('dotnet-trx tests', () => {
fs.writeFileSync(outputPath, report)
})
it('matches report snapshot (only failed tests)', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'dotnet-trx.trx')
const outputPath = path.join(__dirname, '__outputs__', 'dotnet-trx-only-failed.md')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const opts: ParseOptions = {
parseErrors: true,
trackedFiles: ['DotnetTests.Unit/Calculator.cs', 'DotnetTests.XUnitTests/CalculatorTests.cs']
//workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/dotnet/'
}
const parser = new DotnetTrxParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()
const reportOptions: ReportOptions = {
...DEFAULT_OPTIONS,
listSuites: 'all',
listTests: 'failed'
}
const report = getReport([result], reportOptions)
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
it('report from FluentValidation test results matches snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'FluentValidation.Tests.trx')
const outputPath = path.join(__dirname, '__outputs__', 'fluent-validation-test-results.md')