fixed bad merge of gvanhove's describe exception fix
This commit is contained in:
parent
61de2268fe
commit
b02aa9840a
@ -3,7 +3,7 @@ describe('Exceptions:', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new jasmine.Env();
|
env = new jasmine.Env();
|
||||||
env.updateInterval = 0;
|
env.updateInterval = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('jasmine.formatException formats Firefox exception messages as expected', function() {
|
it('jasmine.formatException formats Firefox exception messages as expected', function() {
|
||||||
@ -101,7 +101,49 @@ describe('Exceptions:', function() {
|
|||||||
expect(blockResults[0].message).toMatch(/fake error 3/);
|
expect(blockResults[0].message).toMatch(/fake error 3/);
|
||||||
|
|
||||||
expect(specResults[4].passed()).toEqual(true);
|
expect(specResults[4].passed()).toEqual(true);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
|
||||||
|
var suite = env.describe("a top level describe block that throws an exception", function () {
|
||||||
|
env.it("is a test that should pass", function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
throw new Error("top level error");
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.execute();
|
||||||
|
var suiteResults = suite.results();
|
||||||
|
var specResults = suiteResults.getItems();
|
||||||
|
|
||||||
|
expect(suiteResults.passed()).toEqual(false);
|
||||||
|
expect(specResults.length).toEqual(2);
|
||||||
|
|
||||||
|
expect(specResults[1].description).toMatch(/encountered a declaration exception/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle exceptions thrown directly in nested describe blocks and continue", function () {
|
||||||
|
var suite = env.describe("a top level describe", function () {
|
||||||
|
env.describe("a mid-level describe that throws an exception", function () {
|
||||||
|
env.it("is a test that should pass", function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
throw new Error("a mid-level error");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.execute();
|
||||||
|
var suiteResults = suite.results();
|
||||||
|
var specResults = suiteResults.getItems();
|
||||||
|
|
||||||
|
expect(suiteResults.passed()).toEqual(false);
|
||||||
|
expect(specResults.length).toEqual(1);
|
||||||
|
|
||||||
|
var nestedSpecResults = specResults[0].getItems();
|
||||||
|
|
||||||
|
expect(nestedSpecResults.length).toEqual(2);
|
||||||
|
expect(nestedSpecResults[1].description).toMatch(/encountered a declaration exception/);
|
||||||
|
});
|
||||||
});
|
});
|
@ -1225,6 +1225,9 @@ describe("jasmine spec running", function () {
|
|||||||
this.expect(true).toEqual(true);
|
this.expect(true).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
throw new Error("fake error");
|
||||||
|
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
}
|
}
|
||||||
@ -1240,14 +1243,16 @@ describe("jasmine spec running", function () {
|
|||||||
|
|
||||||
expect(specs.join('')).toMatch(new RegExp(
|
expect(specs.join('')).toMatch(new RegExp(
|
||||||
'Spec: outer1 inner1 should thingy.' +
|
'Spec: outer1 inner1 should thingy.' +
|
||||||
'Result: Passed.' +
|
'Result: Passed.' +
|
||||||
'Spec: outer1 encountered a declaration exception.' +
|
'Spec: outer1 inner1 encountered a declaration exception.' +
|
||||||
'Result: Error: fake error.*' +
|
'Result: Error: fake error.*' +
|
||||||
'Spec: outer1 inner2 should other thingy.' +
|
'Spec: outer1 inner2 should other thingy.' +
|
||||||
'Result: Passed.' +
|
'Result: Passed.' +
|
||||||
'Spec: outer2 should xxx.' +
|
'Spec: outer1 encountered a declaration exception.' +
|
||||||
'Result: Passed.'
|
'Result: Error: fake error.*' +
|
||||||
));
|
'Spec: outer2 should xxx.' +
|
||||||
|
'Result: Passed.'
|
||||||
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -104,14 +104,14 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
|||||||
declarationError = e;
|
declarationError = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentSuite = parentSuite;
|
|
||||||
|
|
||||||
if (declarationError) {
|
if (declarationError) {
|
||||||
this.it("encountered a declaration exception", function() {
|
this.it("encountered a declaration exception", function() {
|
||||||
throw declarationError;
|
throw declarationError;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.currentSuite = parentSuite;
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user