From cc957f7b30f52d69011aad918dbbb3da6008e0fe Mon Sep 17 00:00:00 2001 From: Nico Jansen Date: Fri, 10 Jul 2020 21:25:37 +0200 Subject: [PATCH] fix(reporter): report event order Report `onAllMutantsTested` before `onMutationTestReportReady` --- .../core/src/reporters/MutationTestReportHelper.ts | 2 +- .../unit/reporters/MutationTestReportHelper.spec.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/src/reporters/MutationTestReportHelper.ts b/packages/core/src/reporters/MutationTestReportHelper.ts index fcb93911b9..f7eb74b618 100644 --- a/packages/core/src/reporters/MutationTestReportHelper.ts +++ b/packages/core/src/reporters/MutationTestReportHelper.ts @@ -57,8 +57,8 @@ export class MutationTestReportHelper { public reportAll(results: MutantResult[]) { const report = this.mutationTestReport(results); - this.reporter.onMutationTestReportReady(report); this.reporter.onAllMutantsTested(results); + this.reporter.onMutationTestReportReady(report); this.determineExitCode(report); } diff --git a/packages/core/test/unit/reporters/MutationTestReportHelper.spec.ts b/packages/core/test/unit/reporters/MutationTestReportHelper.spec.ts index 16b3b19c65..155cfe832e 100644 --- a/packages/core/test/unit/reporters/MutationTestReportHelper.spec.ts +++ b/packages/core/test/unit/reporters/MutationTestReportHelper.spec.ts @@ -51,6 +51,16 @@ describe(MutationTestReportHelper.name, () => { expect(reporterMock.onMutationTestReportReady).calledOnce; }); + it('should report "onAllMutantsTested"', () => { + sut.reportAll([]); + expect(reporterMock.onAllMutantsTested).calledOnce; + }); + + it('should report "onAllMutantsTested" before mutationTestReportReady', () => { + sut.reportAll([]); + expect(reporterMock.onAllMutantsTested).calledBefore(reporterMock.onMutationTestReportReady); + }); + it('should copy thresholds', () => { const actualReport = actReportAll(); expect(actualReport.thresholds).eq(testInjector.options.thresholds);