Skip to content
Browse files

Added regexp matching support for exceptions.

  • Loading branch information...
1 parent 6bb19e2 commit 6d24b73b33be1be3db952ab83d459dd29e8a1566 @rauchg rauchg committed
Showing with 18 additions and 0 deletions.
  1. +18 −0 test/expect.js
View
18 test/expect.js
@@ -88,6 +88,10 @@ describe('expect', function () {
throw 'aaa';
}
+ function itThrowsMessage () {
+ throw new Error('tobi');
+ }
+
var anonItThrows = function () {
a.b.c;
}
@@ -109,6 +113,13 @@ describe('expect', function () {
expect(subject).to.be.an(Error);
+ expect(itThrowsMessage).to.throwException(/tobi/);
+ expect(itThrowsMessage).to.not.throwException(/test/);
+
+ err(function () {
+ expect(itThrowsMessage).to.throwException(/no match/);
+ }, 'expected \'tobi\' to match /no match/');
+
var subject2;
expect(itThrowsString).to.throwException(function (str) {
@@ -117,6 +128,13 @@ describe('expect', function () {
expect(subject2).to.be('aaa');
+ expect(itThrowsString).to.throwException(/aaa/);
+ expect(itThrowsString).to.not.throwException(/bbb/);
+
+ err(function () {
+ expect(itThrowsString).to.throwException(/no match/i);
+ }, 'expected \'aaa\' to match /no match/i');
+
var called = false;
expect(itWorks).to.not.throwError(function () {

0 comments on commit 6d24b73

Please sign in to comment.
Something went wrong with that request. Please try again.