Skip to content

Commit

Permalink
fix(ProgressReporter): don't render when there are no valid mutants t…
Browse files Browse the repository at this point in the history
…o render (#3155)
  • Loading branch information
simondel authored Sep 24, 2021
1 parent f921e9d commit 41c4177
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/reporters/progress-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class ProgressBarReporter extends ProgressKeeper {
}

private render(renderObj: Record<string, unknown>): void {
this.progressBar?.render(renderObj);
if (this.progressBar?.total) {
this.progressBar.render(renderObj);
}
}
}
10 changes: 10 additions & 0 deletions packages/core/test/unit/reporters/progress-reporter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ describe(ProgressBarReporter.name, () => {
progressBarTickTokens = { total: 3, tested: 1, survived: 1 };
expect(progressBar.tick).calledWithMatch(progressBarTickTokens);
});

it('should not render the ProgressBar if all mutants have status "NoCoverage" or are static', () => {
const noCoverageResult = { coveredBy: undefined, static: false };
mutants = [factory.mutantTestCoverage(noCoverageResult), factory.mutantTestCoverage({ static: true })];
sut.onAllMutantsMatchedWithTests(mutants);

sut.onMutantTested(factory.mutantResult(noCoverageResult));

expect(progressBar.render).to.not.have.been.called;
});
});

describe('ProgressBar estimated time for 3 mutants', () => {
Expand Down

0 comments on commit 41c4177

Please sign in to comment.