Skip to content

Commit

Permalink
feat(reporter-api): remove onAllMutantsTested (#4234)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The event `onAllMutantsTested` has been removed. Plugin creators should use `onMutationTestReportReady` instead.
  • Loading branch information
nicojs committed May 27, 2023
1 parent f606ef3 commit 762c023
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 37 deletions.
6 changes: 0 additions & 6 deletions packages/api/src/report/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ export interface Reporter {
*/
onMutantTested?(result: Readonly<MutantResult>): void;

/**
* Called when all mutants were tested
* @param results The immutable results
*/
onAllMutantsTested?(results: ReadonlyArray<Readonly<MutantResult>>): void;

/**
* Called when mutation testing is done
* @param report the mutation test result that is valid according to the mutation-testing-report-schema (json schema)
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/reporters/broadcast-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ export class BroadcastReporter implements StrictReporter {
void this.broadcast('onMutantTested', result);
}

public onAllMutantsTested(results: MutantResult[]): void {
void this.broadcast('onAllMutantsTested', results);
}

public onMutationTestReportReady(report: schema.MutationTestResult, metrics: MutationTestMetricsResult): void {
void this.broadcast('onMutationTestReportReady', report, metrics);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/reporters/dots-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DotsReporter implements Reporter {
process.stdout.write(toLog);
}

public onAllMutantsTested(): void {
public onMutationTestReportReady(): void {
process.stdout.write(os.EOL);
}
}
4 changes: 0 additions & 4 deletions packages/core/src/reporters/event-recorder-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export class EventRecorderReporter implements StrictReporter {
this.work('onMutationTestReportReady', report);
}

public onAllMutantsTested(results: MutantResult[]): void {
this.work('onAllMutantsTested', results);
}

public async wrapUp(): Promise<void> {
await this.createBaseFolderTask;
await Promise.all(this.allWork);
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/reporters/mutation-test-report-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export class MutationTestReportHelper {
public async reportAll(results: MutantResult[]): Promise<void> {
const report = await this.mutationTestReport(results);
const metrics = calculateMutationTestMetrics(report);
this.reporter.onAllMutantsTested(results);
this.reporter.onMutationTestReportReady(report, metrics);
if (this.options.incremental) {
await this.fs.mkdir(path.dirname(this.options.incrementalFile), { recursive: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ProgressAppendOnlyReporter extends ProgressKeeper {
}
}

public onAllMutantsTested(): void {
public onMutationTestReportReady(): void {
if (this.intervalReference) {
clearInterval(this.intervalReference);
}
Expand Down
6 changes: 0 additions & 6 deletions packages/core/test/unit/reporters/broadcast-reporter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ describe(BroadcastReporter.name, () => {
it('should forward "onMutantTested"', async () => {
await actAssertShouldForward('onMutantTested', factory.mutantResult());
});
it('should forward "onAllMutantsTested"', async () => {
await actAssertShouldForward('onAllMutantsTested', [factory.mutantResult()]);
});
it('should forward "onMutationTestReportReady"', async () => {
await actAssertShouldForward(
'onMutationTestReportReady',
Expand Down Expand Up @@ -155,9 +152,6 @@ describe(BroadcastReporter.name, () => {
it('should still broadcast "onMutantTested"', async () => {
await actAssertShouldForward('onMutantTested', factory.mutantResult());
});
it('should still broadcast "onAllMutantsTested"', async () => {
await actAssertShouldForward('onAllMutantsTested', [factory.mutantResult()]);
});
it('should still broadcast "onMutationTestReportReady"', async () => {
await actAssertShouldForward(
'onMutationTestReportReady',
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/unit/reporters/dots-reporter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe(DotsReporter.name, () => {
sinon.stub(process.stdout, 'write');
});

describe('onMutantTested()', () => {
describe(DotsReporter.prototype.onMutantTested.name, () => {
it('should log "." when status is Killed', () => {
sut.onMutantTested(factory.killedMutantResult());
expect(process.stdout.write).to.have.been.calledWith('.');
Expand All @@ -35,9 +35,9 @@ describe(DotsReporter.name, () => {
});
});

describe('onAllMutantsTested()', () => {
describe(DotsReporter.prototype.onMutationTestReportReady.name, () => {
it('should write a new line', () => {
sut.onAllMutantsTested();
sut.onMutationTestReportReady();
expect(process.stdout.write).to.have.been.calledWith(os.EOL);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ describe(MutationTestReportHelper.name, () => {
expect(reporterMock.onMutationTestReportReady).calledOnce;
});

it('should report "onAllMutantsTested"', async () => {
await actReportAll();
expect(reporterMock.onAllMutantsTested).calledOnce;
});

it('should report "onAllMutantsTested" before mutationTestReportReady', async () => {
await actReportAll();
expect(reporterMock.onAllMutantsTested).calledBefore(reporterMock.onMutationTestReportReady);
});

it('should copy thresholds', async () => {
const [actualReport] = await actReportAll();
expect(actualReport.thresholds).eq(testInjector.options.thresholds);
Expand Down
1 change: 0 additions & 1 deletion packages/test-helpers/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ export const ALL_REPORTER_EVENTS: Array<keyof Reporter> = [
'onDryRunCompleted',
'onMutationTestingPlanReady',
'onMutantTested',
'onAllMutantsTested',
'onMutationTestReportReady',
'wrapUp',
];
Expand Down

0 comments on commit 762c023

Please sign in to comment.