mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
feat: parse junit report with message
This commit is contained in:
parent
41662db5ca
commit
70db77d88c
5 changed files with 78 additions and 1 deletions
15
__tests__/__outputs__/junit-with-message.md
Normal file
15
__tests__/__outputs__/junit-with-message.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||

|
||||
|Report|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|fixtures/junit-with-message.xml||1 ❌||1ms|
|
||||
## ❌ <a id="user-content-r0" href="#r0">fixtures/junit-with-message.xml</a>
|
||||
**1** tests were completed in **1ms** with **0** passed, **1** failed and **0** skipped.
|
||||
|Test suite|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|[Test](#r0s0)||1 ❌||1ms|
|
||||
### ❌ <a id="user-content-r0s0" href="#r0s0">Test</a>
|
||||
```
|
||||
Fails
|
||||
❌ Test
|
||||
error.cpp:01
|
||||
```
|
||||
|
|
@ -26,6 +26,38 @@ TestRunResult {
|
|||
}
|
||||
`;
|
||||
|
||||
exports[`jest-junit tests parsing junit report with message succeeds 1`] = `
|
||||
TestRunResult {
|
||||
"path": "fixtures/junit-with-message.xml",
|
||||
"suites": [
|
||||
TestSuiteResult {
|
||||
"groups": [
|
||||
TestGroupResult {
|
||||
"name": "Fails",
|
||||
"tests": [
|
||||
TestCaseResult {
|
||||
"error": {
|
||||
"details": "error.cpp:01
|
||||
Expected: true
|
||||
Which is: false >",
|
||||
"line": undefined,
|
||||
"path": undefined,
|
||||
},
|
||||
"name": "Test",
|
||||
"result": "failed",
|
||||
"time": 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"name": "Test",
|
||||
"totalTime": 1,
|
||||
},
|
||||
],
|
||||
"totalTime": 1,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`jest-junit tests report from #235 testing react components named <ComponentName /> 1`] = `
|
||||
TestRunResult {
|
||||
"path": "fixtures/external/jest/jest-react-component-test-results.xml",
|
||||
|
|
|
|||
10
__tests__/fixtures/junit-with-message.xml
Normal file
10
__tests__/fixtures/junit-with-message.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuites tests="1" failures="1" disabled="0" errors="0" time="0.001" name="Failure">
|
||||
<testsuite name="Test" tests="6" failures="1" disabled="0" errors="0" time="0.001">
|
||||
<testcase name="Test" status="run" time="0" classname="Fails">
|
||||
<failure message="error" type=""><![CDATA[error.cpp:01
|
||||
Expected: true
|
||||
Which is: false >]]></failure>
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
|
@ -125,4 +125,24 @@ describe('jest-junit tests', () => {
|
|||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||
fs.writeFileSync(outputPath, report)
|
||||
})
|
||||
|
||||
it('parsing junit report with message succeeds', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'junit-with-message.xml')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'junit-with-message.md')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles: ['test.js']
|
||||
}
|
||||
|
||||
const parser = new JestJunitParser(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)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export class JestJunitParser implements TestParser {
|
|||
return undefined
|
||||
}
|
||||
|
||||
const details = tc.failure[0]
|
||||
const details = typeof tc.failure[0] === 'string' ? tc.failure[0] : tc.failure[0]['_']
|
||||
let path
|
||||
let line
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue