diff --git a/src/core/Env.js b/src/core/Env.js index f9fa181e..ccddcdfe 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -200,11 +200,11 @@ getJasmineRequireObj().Env = function(j$) { handlingLoadErrors = false; }; - this.deprecated = function(msg) { + this.deprecated = function(deprecation) { var runnable = currentRunnable() || topSuite; - runnable.addDeprecationWarning(msg); - if(typeof console !== 'undefined' && typeof console.warn !== 'undefined') { - console.error('DEPRECATION: ' + msg); + runnable.addDeprecationWarning(deprecation); + if(typeof console !== 'undefined' && typeof console.error === 'function') { + console.error('DEPRECATION:', deprecation); } }; diff --git a/src/core/ExpectationResult.js b/src/core/ExpectationResult.js index c794ec77..b4a43e4f 100644 --- a/src/core/ExpectationResult.js +++ b/src/core/ExpectationResult.js @@ -45,10 +45,14 @@ getJasmineRequireObj().buildExpectationResult = function() { var error = options.error; if (!error) { - try { - throw new Error(message()); - } catch (e) { - error = e; + if (options.stack) { + error = options; + } else { + try { + throw new Error(message()); + } catch (e) { + error = e; + } } } return stackFormatter(error); diff --git a/src/core/Spec.js b/src/core/Spec.js index ef5f0d02..a2fe3910 100644 --- a/src/core/Spec.js +++ b/src/core/Spec.js @@ -152,8 +152,11 @@ getJasmineRequireObj().Spec = function(j$) { return this.getSpecName(this); }; - Spec.prototype.addDeprecationWarning = function(msg) { - this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg })); + Spec.prototype.addDeprecationWarning = function(deprecation) { + if (typeof deprecation === 'string') { + deprecation = { message: deprecation }; + } + this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation)); }; var extractCustomPendingMessage = function(e) { diff --git a/src/core/Suite.js b/src/core/Suite.js index b64d9489..f4aa633b 100644 --- a/src/core/Suite.js +++ b/src/core/Suite.js @@ -148,8 +148,11 @@ getJasmineRequireObj().Suite = function(j$) { } }; - Suite.prototype.addDeprecationWarning = function(msg) { - this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg })); + Suite.prototype.addDeprecationWarning = function(deprecation) { + if (typeof deprecation === 'string') { + deprecation = { message: deprecation }; + } + this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation)); }; function isFailure(args) {