From 1c87060804f129542a2e9315ca676bec68c66584 Mon Sep 17 00:00:00 2001 From: Sheel Choksi Date: Sun, 28 Apr 2013 22:24:54 -0700 Subject: [PATCH] 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. --- spec/core/ExceptionFormatterSpec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/core/ExceptionFormatterSpec.js b/spec/core/ExceptionFormatterSpec.js index f718406b..c62e45c2 100644 --- a/spec/core/ExceptionFormatterSpec.js +++ b/spec/core/ExceptionFormatterSpec.js @@ -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+/) });