Closed
Description
Supporting throwing string (which is a very bad practise anyways) leads to problems like #1439.
import test from 'ava';
test(t => {
t.throws(() => {
throw 'foo';
}, Error);
});
1 failed
[anonymous]
/Users/sindresorhus/dev/private/ava-playground/test.js:4
3: test(t => {
4: t.throws(() => {
5: throw 'foo';
Threw unexpected exception:
'foo'
It's not entirely clear here that the problem is that it's excepting an Error object, but a string was thrown. Instead of improving the error message for this case, we should just disallow throwing a string altogether, so when a string is thrown, we could warn like this:
Threw a string, but the assertion requires an Error object