title: How to assert for an exception using Jasmine?
body: <p>I am trying to write a test for ensuring that an invalid instantiation I am doing produces an exception. The test is as follows:</p>
  
  <pre><code>describe('Dialog Spec', function () {
  "use strict";
  
  it("should throw an exception if called without a container element", function () {
      expect(function() {
          new Dialog({});
      }).toThrow(new Exception("InvalidArgumentException", "Expected container element missing"));
    });
  });
  </code></pre>
  
  <p>The Dialog() class:</p>
  
  <pre><code>function Dialog(args) {
  
      if (undefined === args.containerElement)
          throw new Exception("InvalidArgumentException", "Expected container element missing");
  
      this.containerElement = args.containerElement;
  
    }
  }
  </code></pre>
  
  <p>I'm getting the following failure in jasmine.</p>
  
  <pre><code>Expected function to throw Exception InvalidArgumentException: Expected container element missing , but it threw Exception InvalidArgumentException: Expected container element missing
  </code></pre>
  
  <p>My Exception class:</p>
  
  <pre><code>function Exception(exceptionName, exceptionMessage) {
  
      var name = exceptionName;
      var message = exceptionMessage;
  
      this.toString = function () {
          return "Exception " + name + ": "+ message;
      };
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>