mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Add test using external test report fixture from jest project
This commit is contained in:
parent
7af0073fa3
commit
0919385c06
5 changed files with 30110 additions and 9 deletions
9175
__tests__/__outputs__/jest-test-results.md
Normal file
9175
__tests__/__outputs__/jest-test-results.md
Normal file
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
2317
__tests__/fixtures/external/jest/files.txt
vendored
Normal file
File diff suppressed because it is too large
Load diff
9357
__tests__/fixtures/external/jest/jest-test-results.xml
vendored
Normal file
9357
__tests__/fixtures/external/jest/jest-test-results.xml
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -5,15 +5,16 @@ import {parseJestJunit} from '../src/parsers/jest-junit/jest-junit-parser'
|
|||
import {ParseOptions} from '../src/parsers/parser-types'
|
||||
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', () => {
|
||||
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 = {
|
||||
name: 'jest tests',
|
||||
annotations: true,
|
||||
|
|
@ -28,4 +29,29 @@ describe('jest-junit tests', () => {
|
|||
expect(result.success).toBeFalsy()
|
||||
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()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue