Open jfmengels opened 8 years ago
Could make it specific to t.throws
, and say "assign t.throws() result to a variable before combining it with another assertion", or something like that?
True, the message would be a lot nicer then (though even with a more generic rule, we can still have different error messages).
Unless someone has other ideas of how assertions could be nested together except with t.throws
, I'm leaning towards what @novemberborn said, having one rule for this specific case.
Actually, I do have a different case in mind, but also dealing with t.throws
:
test('foo', t => {
t.throws(() => {
t.is(1, 2);
});
});
I have just received a PR where the contributor added a test resembling this:
This could obviously be simplified to
I think this could have been prevented by telling the user not to use an assertion inside another assertion, though I'm not sure whether the error message would have helped the user know how else to do this.