Handle test reports with no test cases

This commit is contained in:
Michal Dorner 2021-03-07 10:34:20 +01:00
parent a1cbedbccb
commit a9749e3840
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
13 changed files with 114 additions and 18 deletions

View file

@ -7,6 +7,22 @@ import {getReport} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/path-utils'
describe('dotnet-trx tests', () => {
it('produces empty test run result when there are no test cases', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'dotnet-trx.trx')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const opts: ParseOptions = {
parseErrors: true,
trackedFiles: []
}
const parser = new DotnetTrxParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result.tests).toBe(0)
expect(result.result).toBe('success')
})
it('matches report snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'dotnet-trx.trx')
const outputPath = path.join(__dirname, '__outputs__', 'dotnet-trx.md')