Add test using external test report fixture from jest project

This commit is contained in:
Michal Dorner 2021-01-25 10:47:49 +01:00
parent 7af0073fa3
commit 0919385c06
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
5 changed files with 30110 additions and 9 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

2317
__tests__/fixtures/external/jest/files.txt vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,15 +5,16 @@ import {parseJestJunit} from '../src/parsers/jest-junit/jest-junit-parser'
import {ParseOptions} from '../src/parsers/parser-types' import {ParseOptions} from '../src/parsers/parser-types'
import {normalizeFilePath} from '../src/utils/file-utils' import {normalizeFilePath} from '../src/utils/file-utils'
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
const outputPath = path.join(__dirname, '__outputs__', 'jest-junit.md')
const xmlFixture = {
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
}
describe('jest-junit tests', () => { describe('jest-junit tests', () => {
it('matches report snapshot', async () => {
it('report from ./reports/jest test results matches snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
const outputPath = path.join(__dirname, '__outputs__', 'jest-junit.md')
const xmlFixture = {
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
}
const opts: ParseOptions = { const opts: ParseOptions = {
name: 'jest tests', name: 'jest tests',
annotations: true, annotations: true,
@ -28,4 +29,29 @@ describe('jest-junit tests', () => {
expect(result.success).toBeFalsy() expect(result.success).toBeFalsy()
expect(result?.output).toMatchSnapshot() expect(result?.output).toMatchSnapshot()
}) })
it('report from facebook/jest test results matches snapshot', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'jest', 'jest-test-results.xml')
const filesPath = path.join(__dirname, 'fixtures', 'external', 'jest', 'files.txt')
const outputPath = path.join(__dirname, '__outputs__', 'jest-test-results.md')
const xmlFixture = {
path: normalizeFilePath(path.relative(__dirname, fixturePath)),
content: fs.readFileSync(fixturePath, {encoding: 'utf8'})
}
const trackedFiles = fs.readFileSync(filesPath, {encoding: 'utf8'}).split(/\n\r?/g)
const opts: ParseOptions = {
trackedFiles,
name: 'jest tests',
annotations: true,
workDir: '/home/dorny/dorny/jest/'
}
const result = await parseJestJunit([xmlFixture], opts)
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
fs.writeFileSync(outputPath, result?.output?.summary ?? '')
expect(result.success).toBeFalsy()
expect(result?.output).toMatchSnapshot()
})
}) })