Add deprecation messages for things that will change/break in 3.0

[#154746527]
This commit is contained in:
Gregg Van Hove
2018-02-05 14:01:46 -08:00
parent 24bf3489dc
commit c142490c69
8 changed files with 62 additions and 11 deletions

View File

@@ -287,7 +287,7 @@ jasmineRequire.HtmlReporter = function(j$) {
var warningBarClassName = 'jasmine-bar jasmine-warning'; var warningBarClassName = 'jasmine-bar jasmine-warning';
for(i = 0; i < deprecationWarnings.length; i++) { for(i = 0; i < deprecationWarnings.length; i++) {
var warning = deprecationWarnings[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'); var results = find('.jasmine-results');
@@ -365,8 +365,13 @@ jasmineRequire.HtmlReporter = function(j$) {
return this; return this;
function addDeprecationWarnings(result) { function addDeprecationWarnings(result) {
if (result && result.deprecationWarnings && result.deprecationWarnings.length > 0) { if (result && result.deprecationWarnings) {
deprecationWarnings = deprecationWarnings.concat(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);
}
}
} }
} }

View File

@@ -33,7 +33,7 @@ body { overflow-y: scroll; }
.jasmine_html-reporter .jasmine-bar.jasmine-passed { background-color: #007069; } .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-skipped { background-color: #bababa; }
.jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; } .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 { background-color: #fff; color: #aaa; }
.jasmine_html-reporter .jasmine-bar.jasmine-menu a { color: #333; } .jasmine_html-reporter .jasmine-bar.jasmine-menu a { color: #333; }
.jasmine_html-reporter .jasmine-bar a { color: white; } .jasmine_html-reporter .jasmine-bar a { color: white; }

View File

@@ -716,6 +716,8 @@ getJasmineRequireObj().Env = function(j$) {
var self = this; var self = this;
var global = options.global || j$.getGlobal(); var global = options.global || j$.getGlobal();
var hasExecuted = false;
var totalSpecsDefined = 0; var totalSpecsDefined = 0;
var catchExceptions = true; var catchExceptions = true;
@@ -901,6 +903,7 @@ getJasmineRequireObj().Env = function(j$) {
// TODO: fix this naming, and here's where the value comes in // TODO: fix this naming, and here's where the value comes in
this.catchExceptions = function(value) { this.catchExceptions = function(value) {
this.deprecated('The catchExceptions option is deprecated and will be replaced with stopOnSpecFailure in Jasmine 3.0');
catchExceptions = !!value; catchExceptions = !!value;
return catchExceptions; return catchExceptions;
}; };
@@ -954,6 +957,7 @@ getJasmineRequireObj().Env = function(j$) {
options.fail = self.fail; options.fail = self.fail;
options.globalErrors = globalErrors; options.globalErrors = globalErrors;
options.completeOnFirstError = throwOnExpectationFailure && options.isLeaf; options.completeOnFirstError = throwOnExpectationFailure && options.isLeaf;
options.deprecated = self.deprecated;
new j$.QueueRunner(options).execute(); new j$.QueueRunner(options).execute();
}; };
@@ -973,6 +977,12 @@ getJasmineRequireObj().Env = function(j$) {
}; };
this.execute = function(runnablesToRun) { 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(!runnablesToRun) {
if (focusedRunnables.length) { if (focusedRunnables.length) {
runnablesToRun = focusedRunnables; runnablesToRun = focusedRunnables;
@@ -1146,6 +1156,7 @@ getJasmineRequireObj().Env = function(j$) {
var focusedRunnables = []; var focusedRunnables = [];
this.fdescribe = function(description, specDefinitions) { 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'); ensureIsNotNested('fdescribe');
ensureIsFunction(specDefinitions, 'fdescribe'); ensureIsFunction(specDefinitions, 'fdescribe');
var suite = suiteFactory(description); var suite = suiteFactory(description);
@@ -1271,6 +1282,7 @@ getJasmineRequireObj().Env = function(j$) {
}; };
this.fit = function(description, fn, timeout){ 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'); ensureIsNotNested('fit');
ensureIsFunctionOrAsync(fn, 'fit'); ensureIsFunctionOrAsync(fn, 'fit');
var spec = specFactory(description, fn, currentDeclarationSuite, timeout); var spec = specFactory(description, fn, currentDeclarationSuite, timeout);
@@ -1526,6 +1538,9 @@ getJasmineRequireObj().Any = function(j$) {
} }
if (this.expectedObject == Object) { 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'; return typeof other == 'object';
} }
@@ -4336,7 +4351,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
return function() { return function() {
if (!called) { if (!called) {
called = true; called = true;
fn(); fn.apply(null, arguments);
} }
return null; return null;
}; };
@@ -4355,6 +4370,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
this.fail = attrs.fail || function() {}; this.fail = attrs.fail || function() {};
this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} }; this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} };
this.completeOnFirstError = !!attrs.completeOnFirstError; this.completeOnFirstError = !!attrs.completeOnFirstError;
this.deprecated = attrs.deprecated;
} }
QueueRunner.prototype.execute = function() { QueueRunner.prototype.execute = function() {
@@ -4414,9 +4430,13 @@ getJasmineRequireObj().QueueRunner = function(j$) {
clearTimeout(timeoutId); clearTimeout(timeoutId);
self.globalErrors.popListener(handleError); self.globalErrors.popListener(handleError);
}), }),
next = once(function () { next = once(function (err) {
cleanup(); cleanup();
if (err instanceof Error) {
self.deprecated('done callback received an Error object. Jasmine 3.0 will treat this as a failure');
}
function runNext() { function runNext() {
if (self.completeOnFirstError && errored) { if (self.completeOnFirstError && errored) {
self.skipToCleanup(iterativeIndex); self.skipToCleanup(iterativeIndex);

View File

@@ -11,6 +11,8 @@ getJasmineRequireObj().Env = function(j$) {
var self = this; var self = this;
var global = options.global || j$.getGlobal(); var global = options.global || j$.getGlobal();
var hasExecuted = false;
var totalSpecsDefined = 0; var totalSpecsDefined = 0;
var catchExceptions = true; var catchExceptions = true;
@@ -196,6 +198,7 @@ getJasmineRequireObj().Env = function(j$) {
// TODO: fix this naming, and here's where the value comes in // TODO: fix this naming, and here's where the value comes in
this.catchExceptions = function(value) { this.catchExceptions = function(value) {
this.deprecated('The catchExceptions option is deprecated and will be replaced with stopOnSpecFailure in Jasmine 3.0');
catchExceptions = !!value; catchExceptions = !!value;
return catchExceptions; return catchExceptions;
}; };
@@ -249,6 +252,7 @@ getJasmineRequireObj().Env = function(j$) {
options.fail = self.fail; options.fail = self.fail;
options.globalErrors = globalErrors; options.globalErrors = globalErrors;
options.completeOnFirstError = throwOnExpectationFailure && options.isLeaf; options.completeOnFirstError = throwOnExpectationFailure && options.isLeaf;
options.deprecated = self.deprecated;
new j$.QueueRunner(options).execute(); new j$.QueueRunner(options).execute();
}; };
@@ -268,6 +272,12 @@ getJasmineRequireObj().Env = function(j$) {
}; };
this.execute = function(runnablesToRun) { 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(!runnablesToRun) {
if (focusedRunnables.length) { if (focusedRunnables.length) {
runnablesToRun = focusedRunnables; runnablesToRun = focusedRunnables;
@@ -441,6 +451,7 @@ getJasmineRequireObj().Env = function(j$) {
var focusedRunnables = []; var focusedRunnables = [];
this.fdescribe = function(description, specDefinitions) { 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'); ensureIsNotNested('fdescribe');
ensureIsFunction(specDefinitions, 'fdescribe'); ensureIsFunction(specDefinitions, 'fdescribe');
var suite = suiteFactory(description); var suite = suiteFactory(description);
@@ -566,6 +577,7 @@ getJasmineRequireObj().Env = function(j$) {
}; };
this.fit = function(description, fn, timeout){ 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'); ensureIsNotNested('fit');
ensureIsFunctionOrAsync(fn, 'fit'); ensureIsFunctionOrAsync(fn, 'fit');
var spec = specFactory(description, fn, currentDeclarationSuite, timeout); var spec = specFactory(description, fn, currentDeclarationSuite, timeout);

View File

@@ -5,7 +5,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
return function() { return function() {
if (!called) { if (!called) {
called = true; called = true;
fn(); fn.apply(null, arguments);
} }
return null; return null;
}; };
@@ -24,6 +24,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
this.fail = attrs.fail || function() {}; this.fail = attrs.fail || function() {};
this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} }; this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} };
this.completeOnFirstError = !!attrs.completeOnFirstError; this.completeOnFirstError = !!attrs.completeOnFirstError;
this.deprecated = attrs.deprecated;
} }
QueueRunner.prototype.execute = function() { QueueRunner.prototype.execute = function() {
@@ -83,9 +84,13 @@ getJasmineRequireObj().QueueRunner = function(j$) {
clearTimeout(timeoutId); clearTimeout(timeoutId);
self.globalErrors.popListener(handleError); self.globalErrors.popListener(handleError);
}), }),
next = once(function () { next = once(function (err) {
cleanup(); cleanup();
if (err instanceof Error) {
self.deprecated('done callback received an Error object. Jasmine 3.0 will treat this as a failure');
}
function runNext() { function runNext() {
if (self.completeOnFirstError && errored) { if (self.completeOnFirstError && errored) {
self.skipToCleanup(iterativeIndex); self.skipToCleanup(iterativeIndex);

View File

@@ -24,6 +24,9 @@ getJasmineRequireObj().Any = function(j$) {
} }
if (this.expectedObject == Object) { 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'; return typeof other == 'object';
} }

View File

@@ -258,7 +258,7 @@ jasmineRequire.HtmlReporter = function(j$) {
var warningBarClassName = 'jasmine-bar jasmine-warning'; var warningBarClassName = 'jasmine-bar jasmine-warning';
for(i = 0; i < deprecationWarnings.length; i++) { for(i = 0; i < deprecationWarnings.length; i++) {
var warning = deprecationWarnings[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'); var results = find('.jasmine-results');
@@ -336,8 +336,13 @@ jasmineRequire.HtmlReporter = function(j$) {
return this; return this;
function addDeprecationWarnings(result) { function addDeprecationWarnings(result) {
if (result && result.deprecationWarnings && result.deprecationWarnings.length > 0) { if (result && result.deprecationWarnings) {
deprecationWarnings = deprecationWarnings.concat(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);
}
}
} }
} }

View File

@@ -218,6 +218,7 @@ body {
&.jasmine-warning { &.jasmine-warning {
background-color: $pending-color; background-color: $pending-color;
color: $text-color;
} }
&.jasmine-menu { &.jasmine-menu {