mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 14:27:10 +01:00
Merge branch 'dev' into mocha-json
This commit is contained in:
commit
ee126813a2
24 changed files with 3653 additions and 1304 deletions
|
|
@ -145,7 +145,11 @@ export class DartJsonParser implements TestParser {
|
|||
group.tests.sort((a, b) => (a.testStart.test.line ?? 0) - (b.testStart.test.line ?? 0))
|
||||
const tests = group.tests.map(tc => {
|
||||
const error = this.getError(suite, tc)
|
||||
return new TestCaseResult(tc.testStart.test.name, tc.result, tc.time, error)
|
||||
const testName =
|
||||
group.group.name !== undefined && tc.testStart.test.name.startsWith(group.group.name)
|
||||
? tc.testStart.test.name.slice(group.group.name.length).trim()
|
||||
: tc.testStart.test.name.trim()
|
||||
return new TestCaseResult(testName, tc.result, tc.time, error)
|
||||
})
|
||||
return new TestGroupResult(group.group.name, tests)
|
||||
})
|
||||
|
|
@ -157,7 +161,6 @@ export class DartJsonParser implements TestParser {
|
|||
}
|
||||
|
||||
const {trackedFiles} = this.options
|
||||
const message = test.error?.error ?? ''
|
||||
const stackTrace = test.error?.stackTrace ?? ''
|
||||
const print = test.print
|
||||
.filter(p => p.messageType === 'print')
|
||||
|
|
@ -165,6 +168,7 @@ export class DartJsonParser implements TestParser {
|
|||
.join('\n')
|
||||
const details = [print, stackTrace].filter(str => str !== '').join('\n')
|
||||
const src = this.exceptionThrowSource(details, trackedFiles)
|
||||
const message = this.getErrorMessage(test.error?.error ?? '', print)
|
||||
let path
|
||||
let line
|
||||
|
||||
|
|
@ -187,6 +191,21 @@ export class DartJsonParser implements TestParser {
|
|||
}
|
||||
}
|
||||
|
||||
private getErrorMessage(message: string, print: string): string {
|
||||
if (this.sdk === 'flutter') {
|
||||
const uselessMessageRe = /^Test failed\. See exception logs above\.\nThe test description was:/m
|
||||
const flutterPrintRe = /^══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═+\s+(.*)\s+When the exception was thrown, this was the stack:/ms
|
||||
if (uselessMessageRe.test(message)) {
|
||||
const match = print.match(flutterPrintRe)
|
||||
if (match !== null) {
|
||||
return match[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return message || print
|
||||
}
|
||||
|
||||
private exceptionThrowSource(ex: string, trackedFiles: string[]): {path: string; line: number} | undefined {
|
||||
const lines = ex.split(/\r?\n/g)
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,9 @@ export class DotnetTrxParser implements TestParser {
|
|||
}
|
||||
const output = r.unitTestResult.Output
|
||||
const error = output?.length > 0 && output[0].ErrorInfo?.length > 0 ? output[0].ErrorInfo[0] : undefined
|
||||
const duration = parseNetDuration(r.unitTestResult.$.duration)
|
||||
const durationAttr = r.unitTestResult.$.duration
|
||||
const duration = durationAttr ? parseNetDuration(durationAttr) : 0
|
||||
|
||||
const test = new Test(r.testMethod.$.name, r.unitTestResult.$.outcome, duration, error)
|
||||
tc.tests.push(test)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export interface UnitTestResult {
|
|||
$: {
|
||||
testId: string
|
||||
testName: string
|
||||
duration: string
|
||||
duration?: string
|
||||
outcome: Outcome
|
||||
}
|
||||
Output: Output[]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue