Skip to content

Commit a80b18e

Browse files
committedAug 28, 2021
Print a deprecation warning when Jasmine#onComplete is called
1 parent 58ace2d commit a80b18e

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed
 

‎Gruntfile.js

-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,4 @@ module.exports = function(grunt) {
3333

3434
runCommands(commands, done);
3535
});
36-
37-
grunt.loadTasks('tasks');
3836
};

‎lib/jasmine.js

+5
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ function addFiles(kind) {
462462
* @param {function} onCompleteCallback
463463
*/
464464
Jasmine.prototype.onComplete = function(onCompleteCallback) {
465+
this.env.deprecated(
466+
'Jasmine#onComplete is deprecated. Instead of calling onComplete, set ' +
467+
"the Jasmine instance's exitOnCompletion property to false and use the " +
468+
'promise returned from the execute method.'
469+
);
465470
this.completionReporter.onComplete(onCompleteCallback);
466471
};
467472

‎spec/jasmine_spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,13 @@ describe('Jasmine', function() {
456456
it('stores an onComplete function', function() {
457457
var fakeOnCompleteCallback = function() {};
458458
spyOn(this.testJasmine.completionReporter, 'onComplete');
459+
this.testJasmine.env.deprecated = jasmine.createSpy('env.deprecated');
459460

460461
this.testJasmine.onComplete(fakeOnCompleteCallback);
461462
expect(this.testJasmine.completionReporter.onComplete).toHaveBeenCalledWith(fakeOnCompleteCallback);
463+
expect(this.testJasmine.env.deprecated).toHaveBeenCalledWith(
464+
"Jasmine#onComplete is deprecated. Instead of calling onComplete, set the Jasmine instance's exitOnCompletion property to false and use the promise returned from the execute method."
465+
);
462466
});
463467
});
464468

@@ -629,6 +633,10 @@ describe('Jasmine', function() {
629633
});
630634

631635
describe('When #onComplete has been called', function() {
636+
beforeEach(function() {
637+
this.testJasmine.env.deprecated = function() {};
638+
});
639+
632640
it('calls the supplied completion handler with true when the whole suite is green', async function() {
633641
const completionHandler = jasmine.createSpy('completionHandler');
634642
this.testJasmine.onComplete(completionHandler);

‎tasks/jasmine.js

-14
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.