The documentation at https://github.com/pivotal/jasmine/wiki/Matchers includes the following:
expect(function(){fn();}).toThrow(e);
As discussed in this question, the following does not work because we want to pass a function object to expect
rather than the result of calling fn()
expect(fn()).toThrow(e);
Question 1: Does the following work?
expect(fn).toThrow(e);
Question 2: If I've defined an object thing
with a method doIt
, does the following work?
expect(thing.doIt).toThrow(e);
(2a: if so, is there a way to pass arguments to the doIt
method?)
Empirically the answer seems to be yes but I don't trust my understanding of js scoping quite enough to be sure.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…