[jest/ci-stats] when jest fails to execute a test file, report it as a failure (#132527)

This commit is contained in:
Spencer 2022-05-19 08:21:20 -07:00 committed by GitHub
parent d12156ec22
commit dd6dacf003
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,6 +41,7 @@ export default class CiStatsJestReporter extends BaseReporter {
private startTime: number | undefined;
private passCount = 0;
private failCount = 0;
private testExecErrorCount = 0;
private group: CiStatsReportTestsOptions['group'] | undefined;
private readonly testRuns: CiStatsReportTestsOptions['testRuns'] = [];
@ -90,6 +91,10 @@ export default class CiStatsJestReporter extends BaseReporter {
return;
}
if (testResult.testExecError) {
this.testExecErrorCount += 1;
}
let elapsedTime = 0;
for (const t of testResult.testResults) {
const result = t.status === 'failed' ? 'fail' : t.status === 'passed' ? 'pass' : 'skip';
@ -123,7 +128,8 @@ export default class CiStatsJestReporter extends BaseReporter {
}
this.group.durationMs = Date.now() - this.startTime;
this.group.result = this.failCount ? 'fail' : this.passCount ? 'pass' : 'skip';
this.group.result =
this.failCount || this.testExecErrorCount ? 'fail' : this.passCount ? 'pass' : 'skip';
await this.reporter.reportTests({
group: this.group,