toThrowError fails the spec when string is passed
Trying to test the examples of Jasmine fails the last spec "Player #resume should throw an exception if song is already playing", when trying to catch the error. Throwing class (Player.js): Player.prototype.resume = function() { if (this.isPlaying) { throw new Error("song is already playing"); }
Catching spec: describe("#resume", function() { it("should throw an exception if song is already playing", function() { player.play(song);
expect(function() {
player.resume();
}).toThrowError("song is already playing");
});
});
Changing "toThrowError" to "toThrow" fixes the problem: describe("#resume", function() { it("should throw an exception if song is already playing", function() { player.play(song);
expect(function() {
player.resume();
}).toThrow(new Error("song is already playing"));
});
});
It's because jasmine-node currently uses Jasmine v1.3.1 and toThrowError isn't available until v2.0.0