Refactoring & cleanup of whole codebase

Improves report summary and annotations
This commit is contained in:
Michal Dorner 2021-01-31 20:47:55 +01:00
parent 07a0223ee3
commit 60b35d601a
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
20 changed files with 38784 additions and 33667 deletions

View file

@ -1,8 +1,8 @@
import * as fs from 'fs'
import * as path from 'path'
import {parseDotnetTrx} from '../src/parsers/dotnet-trx/dotnet-trx-parser'
import {ParseOptions} from '../src/parsers/parser-types'
import {DotnetTrxParser} from '../src/parsers/dotnet-trx/dotnet-trx-parser'
import {ParseOptions} from '../src/test-parser'
import {getReport} from '../src/report/get-report'
import {normalizeFilePath} from '../src/utils/file-utils'
@ -10,21 +10,20 @@ describe('dotnet-trx tests', () => {
it('matches report snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'dotnet-trx.trx')
const outputPath = path.join(__dirname, '__outputs__', 'dotnet-trx.md')
const xmlFixture = {
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
}
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const opts: ParseOptions = {
annotations: true,
parseErrors: true,
trackedFiles: ['DotnetTests.Unit/Calculator.cs', 'DotnetTests.XUnitTests/CalculatorTests.cs'],
workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/dotnet/'
}
const result = await parseDotnetTrx([xmlFixture], opts)
const parser = new DotnetTrxParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()
const report = getReport(result.testRuns)
const report = getReport([result])
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})
@ -32,21 +31,20 @@ describe('dotnet-trx tests', () => {
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')
const xmlFixture = {
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
}
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const opts: ParseOptions = {
trackedFiles: [],
annotations: true,
parseErrors: true,
workDir: ''
}
const result = await parseDotnetTrx([xmlFixture], opts)
const parser = new DotnetTrxParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result).toMatchSnapshot()
const report = getReport(result.testRuns, {listTests: 'failed'})
const report = getReport([result], {listTests: 'failed'})
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, report)
})