- THere seems to be a performance regression. Large test suites may throw - Regressions: Mock Clock won't install correctly, async specs are temporarily not supported. - Async spec runs/waits interface is gone. Blocks are gone. - Move most global usage into jasmine.Env constructor. - Remove optional 'Jasmine running' from HtmlReporter -- caused NS_FACTORY_ERROR in firefox when tested
96 lines
3.0 KiB
JavaScript
96 lines
3.0 KiB
JavaScript
describe('Exceptions:', function() {
|
|
var env;
|
|
|
|
beforeEach(function() {
|
|
env = new jasmine.Env();
|
|
env.updateInterval = 0;
|
|
});
|
|
|
|
it('jasmine.formatException formats Firefox exception messages as expected', function() {
|
|
var sampleFirefoxException = {
|
|
fileName: 'foo.js',
|
|
line: '1978',
|
|
message: 'you got your foo in my bar',
|
|
name: 'A Classic Mistake'
|
|
};
|
|
|
|
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
|
|
|
expect(jasmine.util.formatException(sampleFirefoxException)).toEqual(expected);
|
|
});
|
|
|
|
it('jasmine.formatException formats Webkit exception messages as expected', function() {
|
|
var sampleWebkitException = {
|
|
sourceURL: 'foo.js',
|
|
lineNumber: '1978',
|
|
message: 'you got your foo in my bar',
|
|
name: 'A Classic Mistake'
|
|
};
|
|
|
|
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
|
|
|
expect(jasmine.util.formatException(sampleWebkitException)).toEqual(expected);
|
|
});
|
|
|
|
describe('with break on exception', function() {
|
|
it('should not catch the exception', function() {
|
|
var oldCatch = jasmine.CATCH_EXCEPTIONS;
|
|
jasmine.CATCH_EXCEPTIONS = false;
|
|
env = new jasmine.Env();
|
|
var suite = env.describe('suite for break on exceptions', function() {
|
|
env.it('should break when an exception is thrown', function() {
|
|
throw new Error('I should hit a breakpoint!');
|
|
});
|
|
});
|
|
var runner = env.currentRunner();
|
|
var dont_change = 'I will never change!';
|
|
|
|
try {
|
|
suite.execute();
|
|
dont_change = 'oops I changed';
|
|
}
|
|
catch (e) {}
|
|
finally {
|
|
jasmine.CATCH_EXCEPTIONS = oldCatch;
|
|
}
|
|
|
|
expect(dont_change).toEqual('I will never change!');
|
|
});
|
|
});
|
|
|
|
describe("with catch on exception", function() {
|
|
it('should handle exceptions thrown, but continue', function() {
|
|
var ranSecondTest = false,
|
|
suite = env.describe('Suite for handles exceptions', function () {
|
|
env.it('should be a test that fails because it throws an exception', function() {
|
|
throw new Error();
|
|
});
|
|
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
|
ranSecondTest = true;
|
|
});
|
|
});
|
|
|
|
suite.execute();
|
|
expect(ranSecondTest).toBe(true);
|
|
});
|
|
|
|
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
|
|
var ranSecondDescribe = false, suite, suite2, runner = env.currentRunner();
|
|
suite = env.describe("a suite 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");
|
|
});
|
|
suite2 = env.describe("a suite that doesn't throw an exception", function () {
|
|
ranSecondDescribe = true;
|
|
});
|
|
|
|
runner.execute();
|
|
expect(ranSecondDescribe).toBe(true);
|
|
});
|
|
});
|
|
|
|
});
|