mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Add SwiftXunitParser class based on JavaJunitParser for swift-xunit reporter
This commit is contained in:
parent
6a1c2425d8
commit
1c044b4aef
8 changed files with 122 additions and 0 deletions
34
__tests__/swift-xunit.test.ts
Normal file
34
__tests__/swift-xunit.test.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
import {SwiftXunitParser} from '../src/parsers/swift-xunit/swift-xunit-parser'
|
||||
import {ParseOptions} from '../src/test-parser'
|
||||
import {getReport} from '../src/report/get-report'
|
||||
import {normalizeFilePath} from '../src/utils/path-utils'
|
||||
|
||||
describe('swift-xunit tests', () => {
|
||||
it('report from swift test results matches snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'swift-xunit.xml')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'swift-xunit.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const trackedFiles = [
|
||||
'Package.swift',
|
||||
'Sources/AcmeLib/AcmeLib.swift',
|
||||
'Tests/AcmeLibTests/AcmeLibTests.swift',
|
||||
]
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles
|
||||
}
|
||||
|
||||
const parser = new SwiftXunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport([result])
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue