Remove jasmine.CATCH_EXCEPTIONS

- HTMLReporters should be rewritten to make this sort of thing easier.
- Fix HTMLReporter try/catch switch
- We can't really call resultCallback & throw, so that's been reverted
  for now.
This commit is contained in:
Rajan Agaskar
2012-12-07 17:26:59 -08:00
parent 98c99c4ebb
commit 43552494ee
15 changed files with 78 additions and 84 deletions

View File

@@ -53,7 +53,7 @@
jasmine.util.extend(window, jasmineInterface); jasmine.util.extend(window, jasmineInterface);
} }
var htmlReporter = new jasmine.HtmlReporter(null, jasmine); var htmlReporter = new jasmine.HtmlReporter(null, jasmine, env);
env.addReporter(jasmineInterface.jsApiReporter); env.addReporter(jasmineInterface.jsApiReporter);
env.addReporter(htmlReporter); env.addReporter(htmlReporter);

View File

@@ -46,7 +46,7 @@ jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
if (parent) { if (parent) {
if (typeof this.views.suites[parent.id] == 'undefined') { if (typeof this.views.suites[parent.id] == 'undefined') {
this.views.suites[parent.id] = new this.jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views, this.jasmine); this.views.suites[parent.id] = new this.jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views, this.jasmine, this.catchExceptions);
} }
parentDiv = this.views.suites[parent.id].element; parentDiv = this.views.suites[parent.id].element;
} }
@@ -62,11 +62,13 @@ jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
} }
}; };
jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) { jasmine.HtmlReporter = function(_doc, jasmine, env, options) {
options = options || {};
var self = this; var self = this;
this.jasmine = jasmine || window.jasmine; this.jasmine = jasmine || window.jasmine;
var doc = _doc || window.document; var doc = _doc || window.document;
var reporterView; var reporterView;
var dom = {}; var dom = {};
@@ -84,7 +86,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
doc.body.appendChild(dom.reporter); doc.body.appendChild(dom.reporter);
setExceptionHandling(); setExceptionHandling();
reporterView = new self.jasmine.HtmlReporter.ReporterView(dom, self.jasmine); reporterView = new self.jasmine.HtmlReporter.ReporterView(dom, self.jasmine, env.catchingExceptions());
reporterView.addSpecs(specs, self.specFilter); reporterView.addSpecs(specs, self.specFilter);
}; };
@@ -101,7 +103,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
var lastYieldForRender = 0; var lastYieldForRender = 0;
var refreshInterval = 250; var refreshInterval = 250;
yieldForRender = yieldForRender || function(fn) { var yieldForRender = options.yieldForRender || function(fn) {
var now = Date.now(); var now = Date.now();
var delta = (now - lastYieldForRender); var delta = (now - lastYieldForRender);
if (delta > refreshInterval) { if (delta > refreshInterval) {
@@ -180,7 +182,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
} }
function searchWithCatch() { function searchWithCatch() {
var params = jasmine.HtmlReporter.parameters(window.document); var params = self.jasmine.HtmlReporter.parameters(window.document);
var removed = false; var removed = false;
var i = 0; var i = 0;
@@ -191,7 +193,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
} }
i++; i++;
} }
if (self.jasmine.CATCH_EXCEPTIONS) { if (env.catchingExceptions()) {
params.push("catch=false"); params.push("catch=false");
} }
@@ -203,7 +205,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
if (noTryCatch()) { if (noTryCatch()) {
chxCatch.setAttribute('checked', true); chxCatch.setAttribute('checked', true);
self.jasmine.CATCH_EXCEPTIONS = false; env.catchExceptions(false);
} }
chxCatch.onclick = function() { chxCatch.onclick = function() {
window.location.search = searchWithCatch(); window.location.search = searchWithCatch();
@@ -236,7 +238,7 @@ jasmine.HtmlReporter.sectionLink = function(sectionName, catchExceptions) {
return link; return link;
}; };
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter); jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
jasmine.HtmlReporter.ReporterView = function(dom, jasmine) { jasmine.HtmlReporter.ReporterView = function(dom, jasmine, catchExceptions) {
this.startedAt = new Date(); this.startedAt = new Date();
this.runningSpecCount = 0; this.runningSpecCount = 0;
this.completeSpecCount = 0; this.completeSpecCount = 0;
@@ -270,7 +272,7 @@ jasmine.HtmlReporter.ReporterView = function(dom, jasmine) {
for (var i = 0; i < specs.length; i++) { for (var i = 0; i < specs.length; i++) {
var spec = specs[i]; var spec = specs[i];
this.views.specs[spec.id] = new this.jasmine.HtmlReporter.SpecView(spec, dom, this.views, this.jasmine); this.views.specs[spec.id] = new this.jasmine.HtmlReporter.SpecView(spec, dom, this.views, this.jasmine, catchExceptions);
if (specFilter(spec)) { if (specFilter(spec)) {
this.runningSpecCount++; this.runningSpecCount++;
} }
@@ -320,14 +322,14 @@ jasmine.HtmlReporter.ReporterView = function(dom, jasmine) {
// currently running UI // currently running UI
if (isUndefined(this.runningAlert)) { if (isUndefined(this.runningAlert)) {
this.runningAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, this.jasmine.CATCH_EXCEPTIONS), className: "runningAlert bar" }); this.runningAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, catchExceptions), className: "runningAlert bar" });
dom.alert.appendChild(this.runningAlert); dom.alert.appendChild(this.runningAlert);
} }
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount); this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
// skipped specs UI // skipped specs UI
if (isUndefined(this.skippedAlert)) { if (isUndefined(this.skippedAlert)) {
this.skippedAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, this.jasmine.CATCH_EXCEPTIONS), className: "skippedAlert bar" }); this.skippedAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, catchExceptions), className: "skippedAlert bar" });
} }
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all"; this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
@@ -338,7 +340,7 @@ jasmine.HtmlReporter.ReporterView = function(dom, jasmine) {
// passing specs UI // passing specs UI
if (isUndefined(this.passedAlert)) { if (isUndefined(this.passedAlert)) {
this.passedAlert = this.createDom('span', { href: this.jasmine.HtmlReporter.sectionLink(null, this.jasmine.CATCH_EXCEPTIONS), className: "passingAlert bar" }); this.passedAlert = this.createDom('span', { href: this.jasmine.HtmlReporter.sectionLink(null, catchExceptions), className: "passingAlert bar" });
} }
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount); this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
@@ -401,11 +403,12 @@ jasmine.HtmlReporter.ReporterView = function(dom, jasmine) {
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView); jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
jasmine.HtmlReporter.SpecView = function(spec, dom, views, jasmine) { jasmine.HtmlReporter.SpecView = function(spec, dom, views, jasmine, catchExceptions) {
this.spec = spec; this.spec = spec;
this.dom = dom; this.dom = dom;
this.views = views; this.views = views;
this.jasmine = jasmine || {}; this.jasmine = jasmine || {};
this.catchExceptions = catchExceptions;
this.symbol = this.createDom('li', { className: 'pending' }); this.symbol = this.createDom('li', { className: 'pending' });
this.dom.symbolSummary.appendChild(this.symbol); this.dom.symbolSummary.appendChild(this.symbol);
@@ -413,7 +416,9 @@ jasmine.HtmlReporter.SpecView = function(spec, dom, views, jasmine) {
this.summary = this.createDom('div', { className: 'specSummary' }, this.summary = this.createDom('div', { className: 'specSummary' },
this.createDom('a', { this.createDom('a', {
className: 'description', className: 'description',
href: this.jasmine.HtmlReporter.sectionLink(this.spec.getFullName(), this.jasmine.CATCH_EXCEPTIONS), //TODO: sectionLink is a dependency passed in that knows about catchingExceptions
//so we don't pass catchExceptions everywhere.
href: this.jasmine.HtmlReporter.sectionLink(this.spec.getFullName(), catchExceptions),
title: this.spec.getFullName() title: this.spec.getFullName()
}, this.spec.description) }, this.spec.description)
); );
@@ -480,14 +485,15 @@ jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
}; };
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView); jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);
jasmine.HtmlReporter.SuiteView = function(suite, dom, views, jasmine) { jasmine.HtmlReporter.SuiteView = function(suite, dom, views, jasmine, catchExceptions) {
this.suite = suite; this.suite = suite;
this.dom = dom; this.dom = dom;
this.views = views; this.views = views;
this.jasmine = jasmine || {}; this.jasmine = jasmine || {};
this.catchExceptions = catchExceptions;
this.element = this.createDom('div', { className: 'suite' }, this.element = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'description', href: this.jasmine.HtmlReporter.sectionLink(this.suite.getFullName(), this.jasmine.CATCH_EXCEPTIONS) }, this.suite.description) this.createDom('a', { className: 'description', href: this.jasmine.HtmlReporter.sectionLink(this.suite.getFullName(), catchExceptions) }, this.suite.description)
); );
this.appendToSummary(this.suite, this.element); this.appendToSummary(this.suite, this.element);

View File

@@ -46,13 +46,6 @@ jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
*/ */
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
/**
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
* Set to false to let the exception bubble up in the browser.
*
*/
jasmine.CATCH_EXCEPTIONS = true;
jasmine.getGlobal = function() { jasmine.getGlobal = function() {
function getGlobal() { function getGlobal() {
return this; return this;
@@ -480,6 +473,7 @@ jasmine.buildExpectationResult = function(params) {
var self = this; var self = this;
var global = options.global || jasmine.getGlobal(); var global = options.global || jasmine.getGlobal();
var catchExceptions = true;
var encourageGC = options.encourageGarbageCollection || encourageGarbageCollection; var encourageGC = options.encourageGarbageCollection || encourageGarbageCollection;
this.clock = new jasmine.Clock(global, new jasmine.DelayedFunctionScheduler()); this.clock = new jasmine.Clock(global, new jasmine.DelayedFunctionScheduler());
@@ -492,7 +486,6 @@ jasmine.buildExpectationResult = function(params) {
this.currentRunner_ = new jasmine.Runner(this, isSuite); this.currentRunner_ = new jasmine.Runner(this, isSuite);
this.spies_ = []; this.spies_ = [];
this.currentSpec = null; this.currentSpec = null;
this.catchExceptions = jasmine.CATCH_EXCEPTIONS;
this.undefined = jasmine.undefined; this.undefined = jasmine.undefined;
this.reporter = new jasmine.MultiReporter(); this.reporter = new jasmine.MultiReporter();
@@ -558,6 +551,14 @@ jasmine.buildExpectationResult = function(params) {
return buildExpectationResult(attrs); return buildExpectationResult(attrs);
}; };
this.catchExceptions = function(value) {
return catchExceptions = !!value;
}
this.catchingExceptions = function(value) {
return catchExceptions;
}
this.specFactory = function(description, fn, suite) { this.specFactory = function(description, fn, suite) {
var spec = new specConstructor({ var spec = new specConstructor({
id: self.nextSpecId(), id: self.nextSpecId(),
@@ -569,7 +570,7 @@ jasmine.buildExpectationResult = function(params) {
getSpecName: function(spec) { return getSpecName(spec, suite) }, getSpecName: function(spec) { return getSpecName(spec, suite) },
startCallback: startCallback, startCallback: startCallback,
description: description, description: description,
catchExceptions: self.catchExceptions, catchingExceptions: this.catchingExceptions,
expectationResultFactory: expectationResultFactory, expectationResultFactory: expectationResultFactory,
fn: fn fn: fn
}); });
@@ -1887,7 +1888,7 @@ jasmine.Spec = function(attrs) {
this.fn = attrs.fn; this.fn = attrs.fn;
this.beforeFns = attrs.beforeFns || function() {}; this.beforeFns = attrs.beforeFns || function() {};
this.afterFns = attrs.afterFns || function() {}; this.afterFns = attrs.afterFns || function() {};
this.catchExceptions = attrs.catchExceptions; this.catchingExceptions = attrs.catchingExceptions;
this.startCallback = attrs.startCallback || function() {}; this.startCallback = attrs.startCallback || function() {};
this.exceptionFormatter = attrs.exceptionFormatter || function() {}; this.exceptionFormatter = attrs.exceptionFormatter || function() {};
this.getSpecName = attrs.getSpecName; this.getSpecName = attrs.getSpecName;
@@ -1933,8 +1934,9 @@ jasmine.Spec.prototype.execute = function() {
message: self.exceptionFormatter(e), message: self.exceptionFormatter(e),
trace: e trace: e
})); }));
if (!self.catchExceptions) { if (!self.catchingExceptions()) {
resultCallback(); //TODO: set a var when we catch an exception and
//use a finally block to close the loop in a nice way..
throw e; throw e;
} }
} }

View File

@@ -34,9 +34,7 @@ describe('Exceptions:', function() {
describe('with break on exception', function() { describe('with break on exception', function() {
it('should not catch the exception', function() { it('should not catch the exception', function() {
var oldCatch = jasmine.CATCH_EXCEPTIONS; env.catchExceptions(false);
jasmine.CATCH_EXCEPTIONS = false;
env = new jasmine.Env();
var suite = env.describe('suite for break on exceptions', function() { var suite = env.describe('suite for break on exceptions', function() {
env.it('should break when an exception is thrown', function() { env.it('should break when an exception is thrown', function() {
throw new Error('I should hit a breakpoint!'); throw new Error('I should hit a breakpoint!');
@@ -50,9 +48,6 @@ describe('Exceptions:', function() {
dont_change = 'oops I changed'; dont_change = 'oops I changed';
} }
catch (e) {} catch (e) {}
finally {
jasmine.CATCH_EXCEPTIONS = oldCatch;
}
expect(dont_change).toEqual('I will never change!'); expect(dont_change).toEqual('I will never change!');
}); });

View File

@@ -158,25 +158,6 @@ describe("Spec", function() {
expect(spec.status()).toBe('failed'); expect(spec.status()).toBe('failed');
}); });
it("calls the resultCallback with a failure when an exception occurs in the spec fn", function() {
//TODO: one day we should pass a stack with this.
var resultCallback = originalJasmine.createSpy('resultCallback'),
spec = new jasmine.Spec({
fn: function() {
throw new Error();
},
catchExceptions: true,
resultCallback: resultCallback
});
expect(resultCallback).not.toHaveBeenCalled();
spec.execute();
expect(resultCallback).toHaveBeenCalledWith(
originalJasmine.objectContaining({status: 'failed'})
);
});
it("throws when an exception occurs in the spec fn if catchExceptions is false", function() { it("throws when an exception occurs in the spec fn if catchExceptions is false", function() {
//TODO: one day we should pass a stack with this. //TODO: one day we should pass a stack with this.
var resultCallback = originalJasmine.createSpy('resultCallback'), var resultCallback = originalJasmine.createSpy('resultCallback'),

View File

@@ -11,7 +11,10 @@ describe("HtmlReporter", function() {
body = document.createElement("body"); body = document.createElement("body");
fakeDocument = { body: body, location: { search: "" } }; fakeDocument = { body: body, location: { search: "" } };
htmlReporter = new jasmine.HtmlReporter(fakeDocument, null, function(fn) { fn() }); htmlReporter = new jasmine.HtmlReporter(fakeDocument, null, {
catchingExceptions: function() { return true; },
catchExceptions: function() { }
}, {yieldForRender: function(fn) { fn() }});
}); });
function fakeSpec(name) { function fakeSpec(name) {

View File

@@ -27,7 +27,6 @@
<!-- include spec files here... --> <!-- include spec files here... -->
<script type="text/javascript" src=".././spec/core/BaseSpec.js"></script>
<script type="text/javascript" src=".././spec/core/CustomMatchersSpec.js"></script> <script type="text/javascript" src=".././spec/core/CustomMatchersSpec.js"></script>
<script type="text/javascript" src=".././spec/core/EnvSpec.js"></script> <script type="text/javascript" src=".././spec/core/EnvSpec.js"></script>
<script type="text/javascript" src=".././spec/core/ExceptionsSpec.js"></script> <script type="text/javascript" src=".././spec/core/ExceptionsSpec.js"></script>

View File

@@ -9,6 +9,7 @@
var self = this; var self = this;
var global = options.global || jasmine.getGlobal(); var global = options.global || jasmine.getGlobal();
var catchExceptions = true;
var encourageGC = options.encourageGarbageCollection || encourageGarbageCollection; var encourageGC = options.encourageGarbageCollection || encourageGarbageCollection;
this.clock = new jasmine.Clock(global, new jasmine.DelayedFunctionScheduler()); this.clock = new jasmine.Clock(global, new jasmine.DelayedFunctionScheduler());
@@ -21,7 +22,6 @@
this.currentRunner_ = new jasmine.Runner(this, isSuite); this.currentRunner_ = new jasmine.Runner(this, isSuite);
this.spies_ = []; this.spies_ = [];
this.currentSpec = null; this.currentSpec = null;
this.catchExceptions = jasmine.CATCH_EXCEPTIONS;
this.undefined = jasmine.undefined; this.undefined = jasmine.undefined;
this.reporter = new jasmine.MultiReporter(); this.reporter = new jasmine.MultiReporter();
@@ -87,6 +87,14 @@
return buildExpectationResult(attrs); return buildExpectationResult(attrs);
}; };
this.catchExceptions = function(value) {
return catchExceptions = !!value;
}
this.catchingExceptions = function(value) {
return catchExceptions;
}
this.specFactory = function(description, fn, suite) { this.specFactory = function(description, fn, suite) {
var spec = new specConstructor({ var spec = new specConstructor({
id: self.nextSpecId(), id: self.nextSpecId(),
@@ -98,7 +106,7 @@
getSpecName: function(spec) { return getSpecName(spec, suite) }, getSpecName: function(spec) { return getSpecName(spec, suite) },
startCallback: startCallback, startCallback: startCallback,
description: description, description: description,
catchExceptions: self.catchExceptions, catchingExceptions: this.catchingExceptions,
expectationResultFactory: expectationResultFactory, expectationResultFactory: expectationResultFactory,
fn: fn fn: fn
}); });

View File

@@ -8,7 +8,7 @@ jasmine.Spec = function(attrs) {
this.fn = attrs.fn; this.fn = attrs.fn;
this.beforeFns = attrs.beforeFns || function() {}; this.beforeFns = attrs.beforeFns || function() {};
this.afterFns = attrs.afterFns || function() {}; this.afterFns = attrs.afterFns || function() {};
this.catchExceptions = attrs.catchExceptions; this.catchingExceptions = attrs.catchingExceptions;
this.startCallback = attrs.startCallback || function() {}; this.startCallback = attrs.startCallback || function() {};
this.exceptionFormatter = attrs.exceptionFormatter || function() {}; this.exceptionFormatter = attrs.exceptionFormatter || function() {};
this.getSpecName = attrs.getSpecName; this.getSpecName = attrs.getSpecName;
@@ -54,8 +54,9 @@ jasmine.Spec.prototype.execute = function() {
message: self.exceptionFormatter(e), message: self.exceptionFormatter(e),
trace: e trace: e
})); }));
if (!self.catchExceptions) { if (!self.catchingExceptions()) {
resultCallback(); //TODO: set a var when we catch an exception and
//use a finally block to close the loop in a nice way..
throw e; throw e;
} }
} }

View File

@@ -46,13 +46,6 @@ jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
*/ */
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
/**
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
* Set to false to let the exception bubble up in the browser.
*
*/
jasmine.CATCH_EXCEPTIONS = true;
jasmine.getGlobal = function() { jasmine.getGlobal = function() {
function getGlobal() { function getGlobal() {
return this; return this;

View File

@@ -1,8 +1,10 @@
jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) { jasmine.HtmlReporter = function(_doc, jasmine, env, options) {
options = options || {};
var self = this; var self = this;
this.jasmine = jasmine || window.jasmine; this.jasmine = jasmine || window.jasmine;
var doc = _doc || window.document; var doc = _doc || window.document;
var reporterView; var reporterView;
var dom = {}; var dom = {};
@@ -20,7 +22,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
doc.body.appendChild(dom.reporter); doc.body.appendChild(dom.reporter);
setExceptionHandling(); setExceptionHandling();
reporterView = new self.jasmine.HtmlReporter.ReporterView(dom, self.jasmine); reporterView = new self.jasmine.HtmlReporter.ReporterView(dom, self.jasmine, env.catchingExceptions());
reporterView.addSpecs(specs, self.specFilter); reporterView.addSpecs(specs, self.specFilter);
}; };
@@ -37,7 +39,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
var lastYieldForRender = 0; var lastYieldForRender = 0;
var refreshInterval = 250; var refreshInterval = 250;
yieldForRender = yieldForRender || function(fn) { var yieldForRender = options.yieldForRender || function(fn) {
var now = Date.now(); var now = Date.now();
var delta = (now - lastYieldForRender); var delta = (now - lastYieldForRender);
if (delta > refreshInterval) { if (delta > refreshInterval) {
@@ -116,7 +118,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
} }
function searchWithCatch() { function searchWithCatch() {
var params = jasmine.HtmlReporter.parameters(window.document); var params = self.jasmine.HtmlReporter.parameters(window.document);
var removed = false; var removed = false;
var i = 0; var i = 0;
@@ -127,7 +129,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
} }
i++; i++;
} }
if (self.jasmine.CATCH_EXCEPTIONS) { if (env.catchingExceptions()) {
params.push("catch=false"); params.push("catch=false");
} }
@@ -139,7 +141,7 @@ jasmine.HtmlReporter = function(_doc, jasmine, yieldForRender) {
if (noTryCatch()) { if (noTryCatch()) {
chxCatch.setAttribute('checked', true); chxCatch.setAttribute('checked', true);
self.jasmine.CATCH_EXCEPTIONS = false; env.catchExceptions(false);
} }
chxCatch.onclick = function() { chxCatch.onclick = function() {
window.location.search = searchWithCatch(); window.location.search = searchWithCatch();

View File

@@ -46,7 +46,7 @@ jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
if (parent) { if (parent) {
if (typeof this.views.suites[parent.id] == 'undefined') { if (typeof this.views.suites[parent.id] == 'undefined') {
this.views.suites[parent.id] = new this.jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views, this.jasmine); this.views.suites[parent.id] = new this.jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views, this.jasmine, this.catchExceptions);
} }
parentDiv = this.views.suites[parent.id].element; parentDiv = this.views.suites[parent.id].element;
} }

View File

@@ -1,4 +1,4 @@
jasmine.HtmlReporter.ReporterView = function(dom, jasmine) { jasmine.HtmlReporter.ReporterView = function(dom, jasmine, catchExceptions) {
this.startedAt = new Date(); this.startedAt = new Date();
this.runningSpecCount = 0; this.runningSpecCount = 0;
this.completeSpecCount = 0; this.completeSpecCount = 0;
@@ -32,7 +32,7 @@ jasmine.HtmlReporter.ReporterView = function(dom, jasmine) {
for (var i = 0; i < specs.length; i++) { for (var i = 0; i < specs.length; i++) {
var spec = specs[i]; var spec = specs[i];
this.views.specs[spec.id] = new this.jasmine.HtmlReporter.SpecView(spec, dom, this.views, this.jasmine); this.views.specs[spec.id] = new this.jasmine.HtmlReporter.SpecView(spec, dom, this.views, this.jasmine, catchExceptions);
if (specFilter(spec)) { if (specFilter(spec)) {
this.runningSpecCount++; this.runningSpecCount++;
} }
@@ -82,14 +82,14 @@ jasmine.HtmlReporter.ReporterView = function(dom, jasmine) {
// currently running UI // currently running UI
if (isUndefined(this.runningAlert)) { if (isUndefined(this.runningAlert)) {
this.runningAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, this.jasmine.CATCH_EXCEPTIONS), className: "runningAlert bar" }); this.runningAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, catchExceptions), className: "runningAlert bar" });
dom.alert.appendChild(this.runningAlert); dom.alert.appendChild(this.runningAlert);
} }
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount); this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
// skipped specs UI // skipped specs UI
if (isUndefined(this.skippedAlert)) { if (isUndefined(this.skippedAlert)) {
this.skippedAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, this.jasmine.CATCH_EXCEPTIONS), className: "skippedAlert bar" }); this.skippedAlert = this.createDom('a', { href: this.jasmine.HtmlReporter.sectionLink(null, catchExceptions), className: "skippedAlert bar" });
} }
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all"; this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
@@ -100,7 +100,7 @@ jasmine.HtmlReporter.ReporterView = function(dom, jasmine) {
// passing specs UI // passing specs UI
if (isUndefined(this.passedAlert)) { if (isUndefined(this.passedAlert)) {
this.passedAlert = this.createDom('span', { href: this.jasmine.HtmlReporter.sectionLink(null, this.jasmine.CATCH_EXCEPTIONS), className: "passingAlert bar" }); this.passedAlert = this.createDom('span', { href: this.jasmine.HtmlReporter.sectionLink(null, catchExceptions), className: "passingAlert bar" });
} }
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount); this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);

View File

@@ -1,8 +1,9 @@
jasmine.HtmlReporter.SpecView = function(spec, dom, views, jasmine) { jasmine.HtmlReporter.SpecView = function(spec, dom, views, jasmine, catchExceptions) {
this.spec = spec; this.spec = spec;
this.dom = dom; this.dom = dom;
this.views = views; this.views = views;
this.jasmine = jasmine || {}; this.jasmine = jasmine || {};
this.catchExceptions = catchExceptions;
this.symbol = this.createDom('li', { className: 'pending' }); this.symbol = this.createDom('li', { className: 'pending' });
this.dom.symbolSummary.appendChild(this.symbol); this.dom.symbolSummary.appendChild(this.symbol);
@@ -10,7 +11,9 @@ jasmine.HtmlReporter.SpecView = function(spec, dom, views, jasmine) {
this.summary = this.createDom('div', { className: 'specSummary' }, this.summary = this.createDom('div', { className: 'specSummary' },
this.createDom('a', { this.createDom('a', {
className: 'description', className: 'description',
href: this.jasmine.HtmlReporter.sectionLink(this.spec.getFullName(), this.jasmine.CATCH_EXCEPTIONS), //TODO: sectionLink is a dependency passed in that knows about catchingExceptions
//so we don't pass catchExceptions everywhere.
href: this.jasmine.HtmlReporter.sectionLink(this.spec.getFullName(), catchExceptions),
title: this.spec.getFullName() title: this.spec.getFullName()
}, this.spec.description) }, this.spec.description)
); );

View File

@@ -1,11 +1,12 @@
jasmine.HtmlReporter.SuiteView = function(suite, dom, views, jasmine) { jasmine.HtmlReporter.SuiteView = function(suite, dom, views, jasmine, catchExceptions) {
this.suite = suite; this.suite = suite;
this.dom = dom; this.dom = dom;
this.views = views; this.views = views;
this.jasmine = jasmine || {}; this.jasmine = jasmine || {};
this.catchExceptions = catchExceptions;
this.element = this.createDom('div', { className: 'suite' }, this.element = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'description', href: this.jasmine.HtmlReporter.sectionLink(this.suite.getFullName(), this.jasmine.CATCH_EXCEPTIONS) }, this.suite.description) this.createDom('a', { className: 'description', href: this.jasmine.HtmlReporter.sectionLink(this.suite.getFullName(), catchExceptions) }, this.suite.description)
); );
this.appendToSummary(this.suite, this.element); this.appendToSummary(this.suite, this.element);