diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index b4ad322a..574ee05d 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -809,14 +809,6 @@ getJasmineRequireObj().Spec = function(j$) { this.result.properties[key] = value; }; - Spec.prototype.expect = function(actual) { - return this.expectationFactory(actual, this); - }; - - Spec.prototype.expectAsync = function(actual) { - return this.asyncExpectationFactory(actual, this); - }; - Spec.prototype.execute = function( queueRunnerFactory, onComplete, @@ -1904,23 +1896,27 @@ getJasmineRequireObj().Env = function(j$) { }; this.expect = function(actual) { - if (!runner.currentRunable()) { + const runable = runner.currentRunable(); + + if (!runable) { throw new Error( "'expect' was used when there was no current spec, this could be because an asynchronous test timed out" ); } - return runner.currentRunable().expect(actual); + return runable.expectationFactory(actual, runable); }; this.expectAsync = function(actual) { - if (!runner.currentRunable()) { + const runable = runner.currentRunable(); + + if (!runable) { throw new Error( "'expectAsync' was used when there was no current spec, this could be because an asynchronous test timed out" ); } - return runner.currentRunable().expectAsync(actual); + return runable.asyncExpectationFactory(actual, runable); }; this.beforeEach = function(beforeEachFunction, timeout) { @@ -9755,14 +9751,6 @@ getJasmineRequireObj().Suite = function(j$) { this.result.properties[key] = value; }; - Suite.prototype.expect = function(actual) { - return this.expectationFactory(actual, this); - }; - - Suite.prototype.expectAsync = function(actual) { - return this.asyncExpectationFactory(actual, this); - }; - Suite.prototype.getFullName = function() { const fullName = []; for ( diff --git a/src/core/Env.js b/src/core/Env.js index 355a22d7..cccb87fb 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -767,23 +767,27 @@ getJasmineRequireObj().Env = function(j$) { }; this.expect = function(actual) { - if (!runner.currentRunable()) { + const runable = runner.currentRunable(); + + if (!runable) { throw new Error( "'expect' was used when there was no current spec, this could be because an asynchronous test timed out" ); } - return runner.currentRunable().expect(actual); + return runable.expectationFactory(actual, runable); }; this.expectAsync = function(actual) { - if (!runner.currentRunable()) { + const runable = runner.currentRunable(); + + if (!runable) { throw new Error( "'expectAsync' was used when there was no current spec, this could be because an asynchronous test timed out" ); } - return runner.currentRunable().expectAsync(actual); + return runable.asyncExpectationFactory(actual, runable); }; this.beforeEach = function(beforeEachFunction, timeout) { diff --git a/src/core/Spec.js b/src/core/Spec.js index 52a24a5d..99d2c9ce 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -70,14 +70,6 @@ getJasmineRequireObj().Spec = function(j$) { this.result.properties[key] = value; }; - Spec.prototype.expect = function(actual) { - return this.expectationFactory(actual, this); - }; - - Spec.prototype.expectAsync = function(actual) { - return this.asyncExpectationFactory(actual, this); - }; - Spec.prototype.execute = function( queueRunnerFactory, onComplete, diff --git a/src/core/Suite.js b/src/core/Suite.js index 553c176f..e24b218d 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -28,14 +28,6 @@ getJasmineRequireObj().Suite = function(j$) { this.result.properties[key] = value; }; - Suite.prototype.expect = function(actual) { - return this.expectationFactory(actual, this); - }; - - Suite.prototype.expectAsync = function(actual) { - return this.asyncExpectationFactory(actual, this); - }; - Suite.prototype.getFullName = function() { const fullName = []; for (