feat: support pytest trace back parsing

This commit is contained in:
Martin Fillafer 2023-03-13 20:29:19 +01:00
parent a007309f5d
commit 7442569c25
5 changed files with 163 additions and 28 deletions

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite name="pytest" errors="0" failures="1" skipped="0" tests="1" time="0.316"
timestamp="2023-03-10T11:26:51.659606" hostname="c29b94e3532a">
<testcase classname="product_changes.tests.first_test.MyTestCase" name="test_something" time="0.075">
<failure message="assert False">mnt/extra-addons/product_changes/tests/first_test.py:6: in test_something
assert False
E assert False
</failure>
</testcase>
</testsuite>
</testsuites>

View file

@ -21,4 +21,24 @@ describe('pytest-junit tests', () => {
expect(result.tests).toBe(1)
expect(result.result).toBe('success')
})
it('test failure with trace back', async () => {
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'pytest', 'report-tb-short.xml')
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
const opts: ParseOptions = {
parseErrors: true,
trackedFiles: []
}
const parser = new PytestJunitParser(opts)
const result = await parser.parse(filePath, fileContent)
expect(result.tests).toBe(1)
expect(result.result).toBe('failed')
expect(result.failedSuites[0].failedGroups[0].failedTests[0].error).toMatchObject({
line: 6,
message: 'assert False'
})
})
})