Skip to content

Commit 4a1178e

Browse files
committed
Only call the completion callback once per call to execute()
1 parent 6b3c747 commit 4a1178e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/jasmine.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,11 @@ Jasmine.prototype.execute = async function(files, filterString) {
559559

560560
await this.loadSpecs();
561561

562-
this.addReporter(this.completionReporter);
562+
if (!this.completionReporterInstalled_) {
563+
this.addReporter(this.completionReporter);
564+
this.completionReporterInstalled_ = true;
565+
}
566+
563567
let overallResult;
564568
this.addReporter({
565569
jasmineDone: r => overallResult = r

spec/jasmine_spec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ describe('Jasmine', function() {
497497
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({specFilter: jasmine.any(Function)});
498498
});
499499

500-
it('adds an exit code reporter', async function() {
500+
it('adds an exit code reporter the first time execute is called', async function() {
501501
const completionReporterSpy = jasmine.createSpyObj('reporter', ['onComplete']);
502502
this.testJasmine.completionReporter = completionReporterSpy;
503503
spyOn(this.testJasmine, 'addReporter');
@@ -506,6 +506,12 @@ describe('Jasmine', function() {
506506

507507
expect(this.testJasmine.addReporter).toHaveBeenCalledWith(completionReporterSpy);
508508
expect(this.testJasmine.completionReporter.exitHandler).toBe(this.testJasmine.checkExit);
509+
this.testJasmine.addReporter.calls.reset();
510+
511+
await this.testJasmine.execute();
512+
expect(this.testJasmine.addReporter).not.toHaveBeenCalledWith(
513+
completionReporterSpy
514+
);
509515
});
510516

511517
describe('when exit is called prematurely', function() {

0 commit comments

Comments
 (0)