Display deprecation warnings in HTML reporter
- Also no longer check for stack since IE doesn't do that [#154746527]
This commit is contained in:
@@ -88,7 +88,8 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
results = [],
|
results = [],
|
||||||
htmlReporterMain,
|
htmlReporterMain,
|
||||||
symbols,
|
symbols,
|
||||||
failedSuites = [];
|
failedSuites = [],
|
||||||
|
deprecationWarnings = [];
|
||||||
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
clearPrior();
|
clearPrior();
|
||||||
@@ -126,6 +127,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stateBuilder.suiteDone(result);
|
stateBuilder.suiteDone(result);
|
||||||
|
addDeprecationWarnings(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.specStarted = function(result) {
|
this.specStarted = function(result) {
|
||||||
@@ -169,6 +171,8 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
failures.push(failure);
|
failures.push(failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDeprecationWarnings(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function(doneResult) {
|
this.jasmineDone = function(doneResult) {
|
||||||
@@ -278,6 +282,14 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
|
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDeprecationWarnings(doneResult);
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
var results = find('.jasmine-results');
|
var results = find('.jasmine-results');
|
||||||
results.appendChild(summary);
|
results.appendChild(summary);
|
||||||
|
|
||||||
@@ -352,6 +364,12 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
function addDeprecationWarnings(result) {
|
||||||
|
if (result && result.deprecationWarnings && result.deprecationWarnings.length > 0) {
|
||||||
|
deprecationWarnings = deprecationWarnings.concat(result.deprecationWarnings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function find(selector) {
|
function find(selector) {
|
||||||
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +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-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; }
|
||||||
|
|||||||
@@ -2011,29 +2011,20 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function(result) {
|
reporter.jasmineDone.and.callFake(function(result) {
|
||||||
expect(result.deprecationWarnings).toEqual([
|
expect(result.deprecationWarnings).toEqual([
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({ message: 'top level deprecation' })
|
||||||
message: 'top level deprecation',
|
|
||||||
stack: jasmine.any(String)
|
|
||||||
})
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
fullName: 'suite',
|
fullName: 'suite',
|
||||||
deprecationWarnings: [
|
deprecationWarnings: [
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({ message: 'suite level deprecation' })
|
||||||
message: 'suite level deprecation',
|
|
||||||
stack: jasmine.any(String)
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
fullName: 'suite spec',
|
fullName: 'suite spec',
|
||||||
deprecationWarnings: [
|
deprecationWarnings: [
|
||||||
jasmine.objectContaining({
|
jasmine.objectContaining({ message: 'spec level deprecation' })
|
||||||
message: 'spec level deprecation',
|
|
||||||
stack: jasmine.any(String)
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,47 @@ describe("New HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when there are deprecation warnings', function() {
|
||||||
|
it('displays the messages in their own alert bars', function() {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
container = document.createElement('div'),
|
||||||
|
getContainer = function() { return container; },
|
||||||
|
reporter = new jasmineUnderTest.HtmlReporter({
|
||||||
|
env: env,
|
||||||
|
getContainer: getContainer,
|
||||||
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
|
});
|
||||||
|
|
||||||
|
reporter.initialize();
|
||||||
|
|
||||||
|
reporter.jasmineStarted({});
|
||||||
|
reporter.specDone({
|
||||||
|
status: 'passed',
|
||||||
|
deprecationWarnings: [{ message: 'spec deprecation' }],
|
||||||
|
failedExpectations: [],
|
||||||
|
passedExpectations: []
|
||||||
|
});
|
||||||
|
reporter.suiteDone({
|
||||||
|
status: 'passed',
|
||||||
|
deprecationWarnings: [{ message: 'suite deprecation' }],
|
||||||
|
failedExpectations: []
|
||||||
|
});
|
||||||
|
reporter.jasmineDone({
|
||||||
|
deprecationWarnings: [{ message: 'global deprecation' }],
|
||||||
|
failedExpectations: []
|
||||||
|
});
|
||||||
|
|
||||||
|
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
|
expect(alertBars.length).toEqual(4);
|
||||||
|
expect(alertBars[1].innerHTML).toMatch(/spec deprecation/);
|
||||||
|
expect(alertBars[1].getAttribute("class")).toEqual('jasmine-bar jasmine-warning');
|
||||||
|
expect(alertBars[2].innerHTML).toMatch(/suite deprecation/);
|
||||||
|
expect(alertBars[3].innerHTML).toMatch(/global deprecation/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("when Jasmine is done", function() {
|
describe("when Jasmine is done", function() {
|
||||||
it("adds a warning to the link title of specs that have no expectations", function() {
|
it("adds a warning to the link title of specs that have no expectations", function() {
|
||||||
if (!window.console) {
|
if (!window.console) {
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
results = [],
|
results = [],
|
||||||
htmlReporterMain,
|
htmlReporterMain,
|
||||||
symbols,
|
symbols,
|
||||||
failedSuites = [];
|
failedSuites = [],
|
||||||
|
deprecationWarnings = [];
|
||||||
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
clearPrior();
|
clearPrior();
|
||||||
@@ -97,6 +98,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stateBuilder.suiteDone(result);
|
stateBuilder.suiteDone(result);
|
||||||
|
addDeprecationWarnings(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.specStarted = function(result) {
|
this.specStarted = function(result) {
|
||||||
@@ -140,6 +142,8 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
failures.push(failure);
|
failures.push(failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDeprecationWarnings(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.jasmineDone = function(doneResult) {
|
this.jasmineDone = function(doneResult) {
|
||||||
@@ -249,6 +253,14 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
|
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessagePrefix + failure.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDeprecationWarnings(doneResult);
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
var results = find('.jasmine-results');
|
var results = find('.jasmine-results');
|
||||||
results.appendChild(summary);
|
results.appendChild(summary);
|
||||||
|
|
||||||
@@ -323,6 +335,12 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
function addDeprecationWarnings(result) {
|
||||||
|
if (result && result.deprecationWarnings && result.deprecationWarnings.length > 0) {
|
||||||
|
deprecationWarnings = deprecationWarnings.concat(result.deprecationWarnings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function find(selector) {
|
function find(selector) {
|
||||||
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,6 +216,10 @@ body {
|
|||||||
background-color: $failing-color;
|
background-color: $failing-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.jasmine-warning {
|
||||||
|
background-color: $pending-color;
|
||||||
|
}
|
||||||
|
|
||||||
&.jasmine-menu {
|
&.jasmine-menu {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
color: $faint-text-color;
|
color: $faint-text-color;
|
||||||
|
|||||||
Reference in New Issue
Block a user