Skip to content

Commit afebe74

Browse files
committed
assert.throws
1 parent fd3a0b0 commit afebe74

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

test/raven.test.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,13 +1188,9 @@ describe('Raven (public API)', function() {
11881188

11891189
it('should re-raise a thrown exception', function() {
11901190
var error = new Error('lol');
1191-
try {
1191+
assert.throws(function() {
11921192
Raven.wrap(function() { throw error; })();
1193-
} catch(e) {
1194-
return assert.equal(e, error);
1195-
}
1196-
// Shouldn't hit this
1197-
assert.isTrue(false);
1193+
}, error);
11981194
});
11991195

12001196
});
@@ -1227,11 +1223,9 @@ describe('Raven (public API)', function() {
12271223
var error = new Error('crap');
12281224
var broken = function() { throw error; };
12291225
this.sinon.stub(Raven, 'captureException');
1230-
try {
1231-
Raven.context({'foo': 'bar'}, broken);
1232-
} catch(e) {
1233-
assert.equal(e, error);
1234-
}
1226+
assert.throws(function() {
1227+
Raven.context({foo: 'bar'}, broken);
1228+
}, error);
12351229
assert.isTrue(Raven.captureException.called);
12361230
assert.deepEqual(Raven.captureException.lastCall.args, [error, {'foo': 'bar'}]);
12371231
});
@@ -1240,11 +1234,9 @@ describe('Raven (public API)', function() {
12401234
var error = new Error('crap');
12411235
var broken = function() { throw error; };
12421236
this.sinon.stub(Raven, 'captureException');
1243-
try {
1237+
assert.throws(function() {
12441238
Raven.context(broken);
1245-
} catch(e) {
1246-
assert.equal(e, error);
1247-
}
1239+
}, error);
12481240
assert.isTrue(Raven.captureException.called);
12491241
assert.deepEqual(Raven.captureException.lastCall.args, [error, undefined]);
12501242
});
@@ -1340,13 +1332,9 @@ describe('Raven (public API)', function() {
13401332
it('should reraise a different error', function() {
13411333
var error = new Error('crap1');
13421334
this.sinon.stub(TraceKit, 'report').throws(error);
1343-
try {
1335+
assert.throws(function() {
13441336
Raven.captureException(new Error('crap2'));
1345-
} catch(e) {
1346-
return assert.equal(e, error);
1347-
}
1348-
// shouldn't hit this
1349-
assert.isTrue(false);
1337+
}, error);
13501338
});
13511339

13521340
it('should capture as a normal message if a string is passed', function() {

0 commit comments

Comments
 (0)