diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js index a5c29417..09f09847 100644 --- a/lib/jasmine-core/jasmine-html.js +++ b/lib/jasmine-core/jasmine-html.js @@ -287,7 +287,7 @@ jasmineRequire.HtmlReporter = function(j$) { var warningBarClassName = 'jasmine-bar jasmine-warning'; for(i = 0; i < deprecationWarnings.length; i++) { var warning = deprecationWarnings[i]; - alert.appendChild(createDom('span', {className: warningBarClassName}, 'DEPRECATION: ' + warning.message)); + alert.appendChild(createDom('span', {className: warningBarClassName}, 'DEPRECATION: ' + warning)); } var results = find('.jasmine-results'); @@ -365,8 +365,13 @@ jasmineRequire.HtmlReporter = function(j$) { return this; function addDeprecationWarnings(result) { - if (result && result.deprecationWarnings && result.deprecationWarnings.length > 0) { - deprecationWarnings = deprecationWarnings.concat(result.deprecationWarnings); + if (result && result.deprecationWarnings) { + for(var i = 0; i < result.deprecationWarnings.length; i++) { + var warning = result.deprecationWarnings[i].message; + if (deprecationWarnings.indexOf(warning) < 0) { + deprecationWarnings.push(warning); + } + } } } diff --git a/lib/jasmine-core/jasmine.css b/lib/jasmine-core/jasmine.css index 3144f266..5207c5b2 100644 --- a/lib/jasmine-core/jasmine.css +++ b/lib/jasmine-core/jasmine.css @@ -33,7 +33,7 @@ body { overflow-y: scroll; } .jasmine_html-reporter .jasmine-bar.jasmine-passed { background-color: #007069; } .jasmine_html-reporter .jasmine-bar.jasmine-skipped { background-color: #bababa; } .jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; } -.jasmine_html-reporter .jasmine-bar.jasmine-warning { background-color: #ba9d37; } +.jasmine_html-reporter .jasmine-bar.jasmine-warning { background-color: #ba9d37; color: #333; } .jasmine_html-reporter .jasmine-bar.jasmine-menu { background-color: #fff; color: #aaa; } .jasmine_html-reporter .jasmine-bar.jasmine-menu a { color: #333; } .jasmine_html-reporter .jasmine-bar a { color: white; } diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index ea582c8f..80fee4a5 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -716,6 +716,8 @@ getJasmineRequireObj().Env = function(j$) { var self = this; var global = options.global || j$.getGlobal(); + var hasExecuted = false; + var totalSpecsDefined = 0; var catchExceptions = true; @@ -901,6 +903,7 @@ getJasmineRequireObj().Env = function(j$) { // TODO: fix this naming, and here's where the value comes in this.catchExceptions = function(value) { + this.deprecated('The catchExceptions option is deprecated and will be replaced with stopOnSpecFailure in Jasmine 3.0'); catchExceptions = !!value; return catchExceptions; }; @@ -954,6 +957,7 @@ getJasmineRequireObj().Env = function(j$) { options.fail = self.fail; options.globalErrors = globalErrors; options.completeOnFirstError = throwOnExpectationFailure && options.isLeaf; + options.deprecated = self.deprecated; new j$.QueueRunner(options).execute(); }; @@ -973,6 +977,12 @@ getJasmineRequireObj().Env = function(j$) { }; this.execute = function(runnablesToRun) { + if (hasExecuted) { + this.deprecated('Executing the same Jasmine multiple times will no longer work in Jasmine 3.0'); + } + + hasExecuted = true; + if(!runnablesToRun) { if (focusedRunnables.length) { runnablesToRun = focusedRunnables; @@ -1146,6 +1156,7 @@ getJasmineRequireObj().Env = function(j$) { var focusedRunnables = []; this.fdescribe = function(description, specDefinitions) { + this.deprecated('fit and fdescribe will cause your suite to report an \'incomplete\' status in Jasmine 3.0'); ensureIsNotNested('fdescribe'); ensureIsFunction(specDefinitions, 'fdescribe'); var suite = suiteFactory(description); @@ -1271,6 +1282,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.fit = function(description, fn, timeout){ + this.deprecated('fit and fdescribe will cause your suite to report an \'incomplete\' status in Jasmine 3.0'); ensureIsNotNested('fit'); ensureIsFunctionOrAsync(fn, 'fit'); var spec = specFactory(description, fn, currentDeclarationSuite, timeout); @@ -1526,6 +1538,9 @@ getJasmineRequireObj().Any = function(j$) { } if (this.expectedObject == Object) { + if (other === null) { + j$.getEnv().deprecated('jasmine.Any(Object) will no longer match null in Jasmine 3.0'); + } return typeof other == 'object'; } @@ -4336,7 +4351,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { return function() { if (!called) { called = true; - fn(); + fn.apply(null, arguments); } return null; }; @@ -4355,6 +4370,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { this.fail = attrs.fail || function() {}; this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} }; this.completeOnFirstError = !!attrs.completeOnFirstError; + this.deprecated = attrs.deprecated; } QueueRunner.prototype.execute = function() { @@ -4414,9 +4430,13 @@ getJasmineRequireObj().QueueRunner = function(j$) { clearTimeout(timeoutId); self.globalErrors.popListener(handleError); }), - next = once(function () { + next = once(function (err) { cleanup(); + if (err instanceof Error) { + self.deprecated('done callback received an Error object. Jasmine 3.0 will treat this as a failure'); + } + function runNext() { if (self.completeOnFirstError && errored) { self.skipToCleanup(iterativeIndex); diff --git a/src/core/Env.js b/src/core/Env.js index af1ad374..c62b7843 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -11,6 +11,8 @@ getJasmineRequireObj().Env = function(j$) { var self = this; var global = options.global || j$.getGlobal(); + var hasExecuted = false; + var totalSpecsDefined = 0; var catchExceptions = true; @@ -196,6 +198,7 @@ getJasmineRequireObj().Env = function(j$) { // TODO: fix this naming, and here's where the value comes in this.catchExceptions = function(value) { + this.deprecated('The catchExceptions option is deprecated and will be replaced with stopOnSpecFailure in Jasmine 3.0'); catchExceptions = !!value; return catchExceptions; }; @@ -249,6 +252,7 @@ getJasmineRequireObj().Env = function(j$) { options.fail = self.fail; options.globalErrors = globalErrors; options.completeOnFirstError = throwOnExpectationFailure && options.isLeaf; + options.deprecated = self.deprecated; new j$.QueueRunner(options).execute(); }; @@ -268,6 +272,12 @@ getJasmineRequireObj().Env = function(j$) { }; this.execute = function(runnablesToRun) { + if (hasExecuted) { + this.deprecated('Executing the same Jasmine multiple times will no longer work in Jasmine 3.0'); + } + + hasExecuted = true; + if(!runnablesToRun) { if (focusedRunnables.length) { runnablesToRun = focusedRunnables; @@ -441,6 +451,7 @@ getJasmineRequireObj().Env = function(j$) { var focusedRunnables = []; this.fdescribe = function(description, specDefinitions) { + this.deprecated('fit and fdescribe will cause your suite to report an \'incomplete\' status in Jasmine 3.0'); ensureIsNotNested('fdescribe'); ensureIsFunction(specDefinitions, 'fdescribe'); var suite = suiteFactory(description); @@ -566,6 +577,7 @@ getJasmineRequireObj().Env = function(j$) { }; this.fit = function(description, fn, timeout){ + this.deprecated('fit and fdescribe will cause your suite to report an \'incomplete\' status in Jasmine 3.0'); ensureIsNotNested('fit'); ensureIsFunctionOrAsync(fn, 'fit'); var spec = specFactory(description, fn, currentDeclarationSuite, timeout); diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index f422b49d..086f330d 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -5,7 +5,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { return function() { if (!called) { called = true; - fn(); + fn.apply(null, arguments); } return null; }; @@ -24,6 +24,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { this.fail = attrs.fail || function() {}; this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} }; this.completeOnFirstError = !!attrs.completeOnFirstError; + this.deprecated = attrs.deprecated; } QueueRunner.prototype.execute = function() { @@ -83,9 +84,13 @@ getJasmineRequireObj().QueueRunner = function(j$) { clearTimeout(timeoutId); self.globalErrors.popListener(handleError); }), - next = once(function () { + next = once(function (err) { cleanup(); + if (err instanceof Error) { + self.deprecated('done callback received an Error object. Jasmine 3.0 will treat this as a failure'); + } + function runNext() { if (self.completeOnFirstError && errored) { self.skipToCleanup(iterativeIndex); diff --git a/src/core/asymmetric_equality/Any.js b/src/core/asymmetric_equality/Any.js index 3f447529..960dd478 100644 --- a/src/core/asymmetric_equality/Any.js +++ b/src/core/asymmetric_equality/Any.js @@ -24,6 +24,9 @@ getJasmineRequireObj().Any = function(j$) { } if (this.expectedObject == Object) { + if (other === null) { + j$.getEnv().deprecated('jasmine.Any(Object) will no longer match null in Jasmine 3.0'); + } return typeof other == 'object'; } diff --git a/src/html/HtmlReporter.js b/src/html/HtmlReporter.js index 724050e6..85c19b77 100644 --- a/src/html/HtmlReporter.js +++ b/src/html/HtmlReporter.js @@ -258,7 +258,7 @@ jasmineRequire.HtmlReporter = function(j$) { var warningBarClassName = 'jasmine-bar jasmine-warning'; for(i = 0; i < deprecationWarnings.length; i++) { var warning = deprecationWarnings[i]; - alert.appendChild(createDom('span', {className: warningBarClassName}, 'DEPRECATION: ' + warning.message)); + alert.appendChild(createDom('span', {className: warningBarClassName}, 'DEPRECATION: ' + warning)); } var results = find('.jasmine-results'); @@ -336,8 +336,13 @@ jasmineRequire.HtmlReporter = function(j$) { return this; function addDeprecationWarnings(result) { - if (result && result.deprecationWarnings && result.deprecationWarnings.length > 0) { - deprecationWarnings = deprecationWarnings.concat(result.deprecationWarnings); + if (result && result.deprecationWarnings) { + for(var i = 0; i < result.deprecationWarnings.length; i++) { + var warning = result.deprecationWarnings[i].message; + if (deprecationWarnings.indexOf(warning) < 0) { + deprecationWarnings.push(warning); + } + } } } diff --git a/src/html/_HTMLReporter.scss b/src/html/_HTMLReporter.scss index de8d0145..8e8fa61f 100644 --- a/src/html/_HTMLReporter.scss +++ b/src/html/_HTMLReporter.scss @@ -218,6 +218,7 @@ body { &.jasmine-warning { background-color: $pending-color; + color: $text-color; } &.jasmine-menu {