Determine overall status in core, not reporters
[#92261606] [#78679648]
This commit is contained in:
committed by
Steve Gravrock
parent
5906a2c05c
commit
db615e4186
@@ -225,10 +225,15 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
if (totalSpecsDefined > 0 || failed) {
|
if (totalSpecsDefined > 0 || failed) {
|
||||||
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
||||||
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
||||||
statusBarClassName += failed ? 'jasmine-failed' : 'jasmine-passed';
|
}
|
||||||
|
|
||||||
|
if (doneResult.overallStatus === 'passed') {
|
||||||
|
statusBarClassName += ' jasmine-passed ';
|
||||||
|
} else if (doneResult.overallStatus === 'incomplete') {
|
||||||
|
statusBarClassName += ' jasmine-incomplete ';
|
||||||
|
statusBarMessage = 'Incomplete: ' + doneResult.incompleteReason + ', ' + statusBarMessage;
|
||||||
} else {
|
} else {
|
||||||
statusBarClassName += 'jasmine-skipped';
|
statusBarClassName += ' jasmine-failed ';
|
||||||
statusBarMessage += 'No specs found';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var seedBar;
|
var seedBar;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ body { overflow-y: scroll; }
|
|||||||
.jasmine_html-reporter .jasmine-bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
.jasmine_html-reporter .jasmine-bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||||
.jasmine_html-reporter .jasmine-bar.jasmine-failed, .jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; border-bottom: 1px solid #eee; }
|
.jasmine_html-reporter .jasmine-bar.jasmine-failed, .jasmine_html-reporter .jasmine-bar.jasmine-errored { background-color: #ca3a11; border-bottom: 1px solid #eee; }
|
||||||
.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-incomplete { background-color: #bababa; }
|
||||||
.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-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; }
|
||||||
|
|||||||
@@ -763,6 +763,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
var random = true;
|
var random = true;
|
||||||
var seed = null;
|
var seed = null;
|
||||||
var suppressLoadErrors = false;
|
var suppressLoadErrors = false;
|
||||||
|
var hasFailures = false;
|
||||||
|
|
||||||
var currentSuite = function() {
|
var currentSuite = function() {
|
||||||
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
|
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
|
||||||
@@ -1045,6 +1046,10 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
}
|
}
|
||||||
currentlyExecutingSuites.pop();
|
currentlyExecutingSuites.pop();
|
||||||
reporter.suiteDone(result);
|
reporter.suiteDone(result);
|
||||||
|
|
||||||
|
if (result.status === 'failed') {
|
||||||
|
hasFailures = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
orderChildren: function(node) {
|
orderChildren: function(node) {
|
||||||
return order.sort(node.children);
|
return order.sort(node.children);
|
||||||
@@ -1071,14 +1076,31 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
processor.execute(function() {
|
processor.execute(function() {
|
||||||
clearResourcesForRunnable(topSuite.id);
|
clearResourcesForRunnable(topSuite.id);
|
||||||
currentlyExecutingSuites.pop();
|
currentlyExecutingSuites.pop();
|
||||||
|
var overallStatus, incompleteReason;
|
||||||
|
|
||||||
|
if (hasFailures || topSuite.result.failedExpectations.length > 0) {
|
||||||
|
overallStatus = 'failed';
|
||||||
|
} else if (focusedRunnables.length > 0) {
|
||||||
|
overallStatus = 'incomplete';
|
||||||
|
incompleteReason = 'fit() or fdescribe() was found';
|
||||||
|
} else if (totalSpecsDefined === 0) {
|
||||||
|
overallStatus = 'incomplete';
|
||||||
|
incompleteReason = 'No specs found';
|
||||||
|
} else {
|
||||||
|
overallStatus = 'passed';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information passed to the {@link Reporter#jasmineDone} event.
|
* Information passed to the {@link Reporter#jasmineDone} event.
|
||||||
* @typedef JasmineDoneInfo
|
* @typedef JasmineDoneInfo
|
||||||
|
* @property {OverallStatus} - The overall result of the sute: 'passed', 'failed', or 'incomplete'.
|
||||||
|
* @property {IncompleteReason} - Explanation of why the suite was incimplete.
|
||||||
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
||||||
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
||||||
*/
|
*/
|
||||||
reporter.jasmineDone({
|
reporter.jasmineDone({
|
||||||
|
overallStatus: overallStatus,
|
||||||
|
incompleteReason: incompleteReason,
|
||||||
order: order,
|
order: order,
|
||||||
failedExpectations: topSuite.result.failedExpectations
|
failedExpectations: topSuite.result.failedExpectations
|
||||||
});
|
});
|
||||||
@@ -1270,6 +1292,10 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
clearResourcesForRunnable(spec.id);
|
clearResourcesForRunnable(spec.id);
|
||||||
currentSpec = null;
|
currentSpec = null;
|
||||||
reporter.specDone(result);
|
reporter.specDone(result);
|
||||||
|
|
||||||
|
if (result.status === 'failed') {
|
||||||
|
hasFailures = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function specStarted(spec) {
|
function specStarted(spec) {
|
||||||
|
|||||||
@@ -2075,4 +2075,215 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Overall status in the jasmineDone event', function() {
|
||||||
|
describe('When everything passes', function() {
|
||||||
|
it('is "passed"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('passed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.it('passes', function() {});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When a spec fails', function() {
|
||||||
|
it('is "failed"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('failed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.it('fails', function() {
|
||||||
|
env.expect(true).toBe(false);
|
||||||
|
});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When a top-level beforeAll fails', function() {
|
||||||
|
it('is "failed"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('failed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.beforeAll(function() {
|
||||||
|
throw new Error('nope');
|
||||||
|
});
|
||||||
|
env.it('does not run', function() {});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When a suite beforeAll fails', function() {
|
||||||
|
it('is "failed"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('failed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.describe('something', function() {
|
||||||
|
env.beforeAll(function() {
|
||||||
|
throw new Error('nope');
|
||||||
|
});
|
||||||
|
env.it('does not run', function() {});
|
||||||
|
});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When a top-level afterAll fails', function() {
|
||||||
|
it('is "failed"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('failed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.afterAll(function() {
|
||||||
|
throw new Error('nope');
|
||||||
|
});
|
||||||
|
env.it('does not run', function() {});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When a suite afterAll fails', function() {
|
||||||
|
it('is "failed"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('failed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.describe('something', function() {
|
||||||
|
env.afterAll(function() {
|
||||||
|
throw new Error('nope');
|
||||||
|
});
|
||||||
|
env.it('does not run', function() {});
|
||||||
|
});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("When there are load errors", function() {
|
||||||
|
it('is "failed"', function(done) {
|
||||||
|
var global = {
|
||||||
|
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
||||||
|
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
|
||||||
|
};
|
||||||
|
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||||
|
|
||||||
|
var env = new jasmineUnderTest.Env();
|
||||||
|
var reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
debugger;
|
||||||
|
expect(e.overallStatus).toEqual('failed');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.it('passes', function() {});
|
||||||
|
global.onerror('Uncaught Error: ENOCHEESE');
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When there are no specs', function() {
|
||||||
|
it('is "incomplete"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('incomplete');
|
||||||
|
expect(e.incompleteReason).toEqual('No specs found');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When a spec is focused', function() {
|
||||||
|
it('is "incomplete"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('incomplete');
|
||||||
|
expect(e.incompleteReason).toEqual('fit() or fdescribe() was found');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.fit('is focused', function() {});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When a suite is focused', function() {
|
||||||
|
it('is "incomplete"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('incomplete');
|
||||||
|
expect(e.incompleteReason).toEqual('fit() or fdescribe() was found');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.fdescribe('something focused', function() {
|
||||||
|
env.it('does a thing', function() {});
|
||||||
|
});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('When there are both failures and focused specs', function() {
|
||||||
|
it('is "failed"', function(done) {
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.overallStatus).toEqual('failed');
|
||||||
|
expect(e.incompleteReason).toBeUndefined();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
env.addReporter(reporter);
|
||||||
|
env.fit('is focused', function() {
|
||||||
|
env.expect(true).toBe(false);
|
||||||
|
});
|
||||||
|
env.execute();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -179,27 +179,6 @@ describe("HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when there are suite failures", function () {
|
describe("when there are suite failures", function () {
|
||||||
it("displays an overall result of failure even if no other failures occurred", 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.suiteDone({ status: 'failed', failedExpectations: [{ message: 'My After All Exception' }] });
|
|
||||||
reporter.jasmineDone({ failedExpectations: [] });
|
|
||||||
|
|
||||||
var alertBar = container.querySelector(".jasmine-overall-result");
|
|
||||||
expect(alertBar.classList).toContain("jasmine-failed");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("displays the exceptions in their own alert bars", function(){
|
it("displays the exceptions in their own alert bars", function(){
|
||||||
var env = new jasmineUnderTest.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
@@ -319,7 +298,7 @@ describe("HtmlReporter", function() {
|
|||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
|
|
||||||
timer.elapsed.and.returnValue(100);
|
timer.elapsed.and.returnValue(100);
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var duration = container.querySelector(".jasmine-alert .jasmine-duration");
|
var duration = container.querySelector(".jasmine-alert .jasmine-duration");
|
||||||
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
||||||
@@ -740,7 +719,7 @@ describe("HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
reporter.jasmineDone();
|
reporter.jasmineDone({});
|
||||||
|
|
||||||
var seedBar = container.querySelector(".jasmine-seed-bar");
|
var seedBar = container.querySelector(".jasmine-seed-bar");
|
||||||
expect(seedBar).toBeNull();
|
expect(seedBar).toBeNull();
|
||||||
@@ -766,79 +745,6 @@ describe("HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows a message if no specs are run", function(){
|
|
||||||
var env, container, reporter;
|
|
||||||
env = new jasmineUnderTest.Env();
|
|
||||||
container = document.createElement("div");
|
|
||||||
var 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.jasmineDone({});
|
|
||||||
|
|
||||||
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
|
|
||||||
expect(alertBars[0].getAttribute('class')).toMatch(/jasmine-skipped/);
|
|
||||||
expect(alertBars[0].innerHTML).toMatch(/No specs found/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("reports failure if there are global errors and no specs", function() {
|
|
||||||
var env = new jasmineUnderTest.Env(),
|
|
||||||
container = document.createElement("div"),
|
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
|
||||||
env: env,
|
|
||||||
getContainer: function() { return container; },
|
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
|
||||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
|
||||||
});
|
|
||||||
reporter.initialize();
|
|
||||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
|
||||||
reporter.jasmineDone({
|
|
||||||
failedExpectations: [{
|
|
||||||
passed: false,
|
|
||||||
message: 'nope'
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
var alertBar = container.querySelector(".jasmine-overall-result");
|
|
||||||
expect(alertBar.getAttribute('class')).toMatch(/jasmine-failed/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("reports failure if there are global errors and some specs", function() {
|
|
||||||
var env = new jasmineUnderTest.Env(),
|
|
||||||
container = document.createElement("div"),
|
|
||||||
reporter = new jasmineUnderTest.HtmlReporter({
|
|
||||||
env: env,
|
|
||||||
getContainer: function() { return container; },
|
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
|
||||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
|
||||||
});
|
|
||||||
reporter.initialize();
|
|
||||||
reporter.jasmineStarted({ totalSpecsDefined: 0 });
|
|
||||||
reporter.specDone({
|
|
||||||
id: 123,
|
|
||||||
description: "with a spec",
|
|
||||||
fullName: "A Suite with a spec",
|
|
||||||
status: "passed",
|
|
||||||
passedExpectations: [{passed: true}],
|
|
||||||
failedExpectations: []
|
|
||||||
});
|
|
||||||
reporter.jasmineDone({
|
|
||||||
failedExpectations: [{
|
|
||||||
passed: false,
|
|
||||||
message: 'nope'
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
var alertBar = container.querySelector(".jasmine-overall-result");
|
|
||||||
expect(alertBar.getAttribute('class')).toMatch(/jasmine-failed/);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("and all specs pass", function() {
|
describe("and all specs pass", function() {
|
||||||
var env, container, reporter;
|
var env, container, reporter;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@@ -877,7 +783,6 @@ describe("HtmlReporter", function() {
|
|||||||
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
|
var alertBars = container.querySelectorAll(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
expect(alertBars.length).toEqual(1);
|
expect(alertBars.length).toEqual(1);
|
||||||
expect(alertBars[0].getAttribute('class')).toMatch(/jasmine-passed/);
|
|
||||||
expect(alertBars[0].innerHTML).toMatch(/2 specs, 0 failures/);
|
expect(alertBars[0].innerHTML).toMatch(/2 specs, 0 failures/);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1042,8 +947,6 @@ describe("HtmlReporter", function() {
|
|||||||
|
|
||||||
it("reports the specs counts", function() {
|
it("reports the specs counts", function() {
|
||||||
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
|
var alertBar = container.querySelector(".jasmine-alert .jasmine-bar");
|
||||||
|
|
||||||
expect(alertBar.getAttribute('class')).toMatch(/jasmine-failed/);
|
|
||||||
expect(alertBar.innerHTML).toMatch(/2 specs, 1 failure/);
|
expect(alertBar.innerHTML).toMatch(/2 specs, 1 failure/);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1086,4 +989,83 @@ describe("HtmlReporter", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("The overall result bar", function() {
|
||||||
|
describe("When the jasmineDone event's overallStatus is 'passed'", function() {
|
||||||
|
it("has class jasmine-passed", 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.jasmineDone({
|
||||||
|
overallStatus: 'passed',
|
||||||
|
failedExpectations: []
|
||||||
|
});
|
||||||
|
|
||||||
|
var alertBar = container.querySelector(".jasmine-overall-result");
|
||||||
|
expect(alertBar.classList).toContain("jasmine-passed");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("When the jasmineDone event's overallStatus is 'failed'", function() {
|
||||||
|
it("has class jasmine-failed", 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.jasmineDone({
|
||||||
|
overallStatus: 'failed',
|
||||||
|
failedExpectations: []
|
||||||
|
});
|
||||||
|
|
||||||
|
var alertBar = container.querySelector(".jasmine-overall-result");
|
||||||
|
expect(alertBar.classList).toContain("jasmine-failed");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("When the jasmineDone event's overallStatus is 'failed'", function() {
|
||||||
|
it("has class jasmine-incomplete", 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.jasmineDone({
|
||||||
|
overallStatus: 'incomplete',
|
||||||
|
incompleteReason: 'because nope',
|
||||||
|
failedExpectations: []
|
||||||
|
});
|
||||||
|
|
||||||
|
var alertBar = container.querySelector(".jasmine-overall-result");
|
||||||
|
expect(alertBar.classList).toContain("jasmine-incomplete");
|
||||||
|
expect(alertBar.textContent).toContain("Incomplete: because nope");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
var random = true;
|
var random = true;
|
||||||
var seed = null;
|
var seed = null;
|
||||||
var suppressLoadErrors = false;
|
var suppressLoadErrors = false;
|
||||||
|
var hasFailures = false;
|
||||||
|
|
||||||
var currentSuite = function() {
|
var currentSuite = function() {
|
||||||
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
|
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
|
||||||
@@ -311,6 +312,10 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
}
|
}
|
||||||
currentlyExecutingSuites.pop();
|
currentlyExecutingSuites.pop();
|
||||||
reporter.suiteDone(result);
|
reporter.suiteDone(result);
|
||||||
|
|
||||||
|
if (result.status === 'failed') {
|
||||||
|
hasFailures = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
orderChildren: function(node) {
|
orderChildren: function(node) {
|
||||||
return order.sort(node.children);
|
return order.sort(node.children);
|
||||||
@@ -337,14 +342,31 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
processor.execute(function() {
|
processor.execute(function() {
|
||||||
clearResourcesForRunnable(topSuite.id);
|
clearResourcesForRunnable(topSuite.id);
|
||||||
currentlyExecutingSuites.pop();
|
currentlyExecutingSuites.pop();
|
||||||
|
var overallStatus, incompleteReason;
|
||||||
|
|
||||||
|
if (hasFailures || topSuite.result.failedExpectations.length > 0) {
|
||||||
|
overallStatus = 'failed';
|
||||||
|
} else if (focusedRunnables.length > 0) {
|
||||||
|
overallStatus = 'incomplete';
|
||||||
|
incompleteReason = 'fit() or fdescribe() was found';
|
||||||
|
} else if (totalSpecsDefined === 0) {
|
||||||
|
overallStatus = 'incomplete';
|
||||||
|
incompleteReason = 'No specs found';
|
||||||
|
} else {
|
||||||
|
overallStatus = 'passed';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information passed to the {@link Reporter#jasmineDone} event.
|
* Information passed to the {@link Reporter#jasmineDone} event.
|
||||||
* @typedef JasmineDoneInfo
|
* @typedef JasmineDoneInfo
|
||||||
|
* @property {OverallStatus} - The overall result of the sute: 'passed', 'failed', or 'incomplete'.
|
||||||
|
* @property {IncompleteReason} - Explanation of why the suite was incimplete.
|
||||||
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
||||||
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
||||||
*/
|
*/
|
||||||
reporter.jasmineDone({
|
reporter.jasmineDone({
|
||||||
|
overallStatus: overallStatus,
|
||||||
|
incompleteReason: incompleteReason,
|
||||||
order: order,
|
order: order,
|
||||||
failedExpectations: topSuite.result.failedExpectations
|
failedExpectations: topSuite.result.failedExpectations
|
||||||
});
|
});
|
||||||
@@ -536,6 +558,10 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
clearResourcesForRunnable(spec.id);
|
clearResourcesForRunnable(spec.id);
|
||||||
currentSpec = null;
|
currentSpec = null;
|
||||||
reporter.specDone(result);
|
reporter.specDone(result);
|
||||||
|
|
||||||
|
if (result.status === 'failed') {
|
||||||
|
hasFailures = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function specStarted(spec) {
|
function specStarted(spec) {
|
||||||
|
|||||||
@@ -196,10 +196,15 @@ jasmineRequire.HtmlReporter = function(j$) {
|
|||||||
if (totalSpecsDefined > 0 || failed) {
|
if (totalSpecsDefined > 0 || failed) {
|
||||||
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
||||||
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
||||||
statusBarClassName += failed ? 'jasmine-failed' : 'jasmine-passed';
|
}
|
||||||
|
|
||||||
|
if (doneResult.overallStatus === 'passed') {
|
||||||
|
statusBarClassName += ' jasmine-passed ';
|
||||||
|
} else if (doneResult.overallStatus === 'incomplete') {
|
||||||
|
statusBarClassName += ' jasmine-incomplete ';
|
||||||
|
statusBarMessage = 'Incomplete: ' + doneResult.incompleteReason + ', ' + statusBarMessage;
|
||||||
} else {
|
} else {
|
||||||
statusBarClassName += 'jasmine-skipped';
|
statusBarClassName += ' jasmine-failed ';
|
||||||
statusBarMessage += 'No specs found';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var seedBar;
|
var seedBar;
|
||||||
|
|||||||
@@ -209,6 +209,11 @@ body {
|
|||||||
background-color: $passing-color;
|
background-color: $passing-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.jasmine-incomplete {
|
||||||
|
background-color: $neutral-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
&.jasmine-skipped {
|
&.jasmine-skipped {
|
||||||
background-color: $neutral-color;
|
background-color: $neutral-color;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user