mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
Add unit tests to better test changes to output in the future
This commit is contained in:
parent
e94b0959b2
commit
b96bed2d8a
9 changed files with 3420 additions and 7 deletions
|
|
@ -3,7 +3,7 @@ import * as path from 'path'
|
|||
|
||||
import {JavaJunitParser} from '../src/parsers/java-junit/java-junit-parser'
|
||||
import {ParseOptions} from '../src/test-parser'
|
||||
import {getReport} from '../src/report/get-report'
|
||||
import {ReportOptions, getReport} from '../src/report/get-report'
|
||||
import {normalizeFilePath} from '../src/utils/path-utils'
|
||||
|
||||
describe('java-junit tests', () => {
|
||||
|
|
@ -90,4 +90,117 @@ describe('java-junit tests', () => {
|
|||
expect(result.result === 'failed')
|
||||
expect(result.failed === 1)
|
||||
})
|
||||
|
||||
it('playwright test report - all tests', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'java', 'playwright-report.xml')
|
||||
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'java', 'files.txt')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'playwright-output-all.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles
|
||||
}
|
||||
|
||||
const reportOpts: ReportOptions = {
|
||||
listSuites: 'all',
|
||||
listTests: 'all',
|
||||
baseUrl: '',
|
||||
onlySummary: false
|
||||
}
|
||||
|
||||
const parser = new JavaJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport([result], reportOpts)
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
it('playwright test report - ignore skipped tests', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'java', 'playwright-report.xml')
|
||||
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'java', 'files.txt')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'playwright-output-no-skipped.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles
|
||||
}
|
||||
|
||||
const reportOpts: ReportOptions = {
|
||||
listSuites: 'all',
|
||||
listTests: 'non-skipped',
|
||||
baseUrl: '',
|
||||
onlySummary: false
|
||||
}
|
||||
|
||||
const parser = new JavaJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport([result], reportOpts)
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
it('playwright test report - only failed', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'java', 'playwright-report.xml')
|
||||
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'java', 'files.txt')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'playwright-output-failed.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles
|
||||
}
|
||||
|
||||
const reportOpts: ReportOptions = {
|
||||
listSuites: 'failed',
|
||||
listTests: 'failed',
|
||||
baseUrl: '',
|
||||
onlySummary: false
|
||||
}
|
||||
|
||||
const parser = new JavaJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport([result], reportOpts)
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
it('playwright test report - only summary', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'java', 'playwright-report.xml')
|
||||
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'java', 'files.txt')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'playwright-output-summary.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles
|
||||
}
|
||||
|
||||
const reportOpts: ReportOptions = {
|
||||
listSuites: 'all',
|
||||
listTests: 'all',
|
||||
baseUrl: '',
|
||||
onlySummary: true
|
||||
}
|
||||
|
||||
const parser = new JavaJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result).toMatchSnapshot()
|
||||
|
||||
const report = getReport([result], reportOpts)
|
||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue