Correct signature of toThrowError

Jasmine expects an Error TYPE not an Error VALUE as first parameter.
This commit is contained in:
Klaus Reimer
2016-03-08 09:26:59 +01:00
parent 9f0f926a12
commit 3379a63609
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -150,6 +150,17 @@ describe("Included matchers:", function () {
expect(foo).not.toThrow();
expect(bar).toThrow();
});
it("The 'toThrowError' matcher is for testing a specific thrown exception", function() {
var foo = function() {
throw new TypeError("foo bar baz");
};
expect(foo).toThrowError("foo bar baz");
expect(foo).toThrowError(/bar/);
expect(foo).toThrowError(TypeError);
expect(foo).toThrowError(TypeError, "foo bar baz");
});
});
describe("A spec", function () {
+1 -1
View File
@@ -297,7 +297,7 @@ declare module jasmine {
toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean;
toThrow(expected?: any): boolean;
toThrowError(message?: string | RegExp): boolean;
toThrowError(expected?: Error, message?: string | RegExp): boolean;
toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean;
not: Matchers;
Any: Any;