Attempt at normalizing error stacks across browsers.

Failed expectations now have a `stack` property, remove `trace.stack`
This commit is contained in:
Dan Hansen and Davis W. Frank
2013-02-27 16:37:31 -08:00
parent dc4563d45c
commit d6da13a8dd
12 changed files with 237 additions and 132 deletions

View File

@@ -1,26 +1,52 @@
describe("ExceptionFormatter", function() {
describe("#message", function() {
it('formats Firefox exception messages', function() {
var sampleFirefoxException = {
fileName: 'foo.js',
lineNumber: '1978',
message: 'you got your foo in my bar',
name: 'A Classic Mistake'
},
exceptionFormatter = new jasmine.ExceptionFormatter(),
message = exceptionFormatter.message(sampleFirefoxException);
it('formats Firefox exception messages', function() {
var sampleFirefoxException = {
fileName: 'foo.js',
line: '1978',
message: 'you got your foo in my bar',
name: 'A Classic Mistake'
},
message = jasmine.exceptionMessageFor(sampleFirefoxException);
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
});
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
it('formats Webkit exception messages', function() {
var sampleWebkitException = {
sourceURL: 'foo.js',
line: '1978',
message: 'you got your foo in my bar',
name: 'A Classic Mistake'
},
exceptionFormatter = new jasmine.ExceptionFormatter(),
message = exceptionFormatter.message(sampleWebkitException);
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
});
it('formats V8 exception messages', function() {
var sampleV8 = {
message: 'you got your foo in my bar',
name: 'A Classic Mistake'
},
exceptionFormatter = new jasmine.ExceptionFormatter(),
message = exceptionFormatter.message(sampleV8);
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
});
});
it('formats Webkit exception messages', function() {
var sampleWebkitException = {
sourceURL: 'foo.js',
lineNumber: '1978',
message: 'you got your foo in my bar',
name: 'A Classic Mistake'
},
message = jasmine.exceptionMessageFor(sampleWebkitException);
describe("#stack", function() {
it("formats stack traces from Webkit, Firefox or node.js", function() {
var error = new Error("an error");
expect(new jasmine.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
});
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
it("returns null if no Error provided", function() {
expect(new jasmine.ExceptionFormatter().stack()).toBeNull();
});
});
});