Fix spec to throw error, ensuring a stack property

In Safari Mac 6.0.4 (and possibly other versions), a new error does
not have the stack property. Throwing the error and then catching it
ensures that the stack property has the correct value.

This fix gets the specs to run green in Safari.
This commit is contained in:
Sheel Choksi
2013-04-28 22:24:54 -07:00
parent fbb9f53524
commit 1c87060804

View File

@@ -41,7 +41,8 @@ describe("ExceptionFormatter", function() {
describe("#stack", function() {
it("formats stack traces from Webkit, Firefox or node.js", function() {
var error = new Error("an error");
var error;
try { throw new Error("an error") } catch(e) { error = e; };
expect(new j$.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
});