{"action":"opened","issue":{"url":"https://api.github.com/repos/avajs/ava/issues/1841","repository_url":"https://api.github.com/repos/avajs/ava","labels_url":"https://api.github.com/repos/avajs/ava/issues/1841/labels{/name}","comments_url":"https://api.github.com/repos/avajs/ava/issues/1841/comments","events_url":"https://api.github.com/repos/avajs/ava/issues/1841/events","html_url":"https://github.com/avajs/ava/issues/1841","id":331800543,"node_id":"MDU6SXNzdWUzMzE4MDA1NDM=","number":1841,"title":"Make exceptions/promise rejections testable with throw() even if they aren't instances of Error","user":{"login":"sth","id":950517,"node_id":"MDQ6VXNlcjk1MDUxNw==","avatar_url":"https://avatars0.githubusercontent.com/u/950517?v=4","gravatar_id":"","url":"https://api.github.com/users/sth","html_url":"https://github.com/sth","followers_url":"https://api.github.com/users/sth/followers","following_url":"https://api.github.com/users/sth/following{/other_user}","gists_url":"https://api.github.com/users/sth/gists{/gist_id}","starred_url":"https://api.github.com/users/sth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sth/subscriptions","organizations_url":"https://api.github.com/users/sth/orgs","repos_url":"https://api.github.com/users/sth/repos","events_url":"https://api.github.com/users/sth/events{/privacy}","received_events_url":"https://api.github.com/users/sth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-13T00:34:34Z","updated_at":"2018-06-13T00:34:34Z","closed_at":null,"author_association":"NONE","body":"In #1704 support for non-`Error` exceptions was removed from `throws()`. Since promise rejections are also tested with `throws()`, this also removed support for promise rejections that are not instances of `Error`. While non-`Error` exceptions might be rare, rejecting promises with non-`Error` values doesn't seem too uncommon.\r\n\r\n`throws()` is now strictly less useful than before. It can still test cases that were previously tested with `throws(x, Error)`, but for other cases it will always fail. Code that throws non-standard exceptions or uses such promises always fails the assertion.\r\n\r\nThe fix in #1704 is based on issue #1440 and a motivating example seems to be #1439, where somebody explicitly specified that an `Error` instance should be thrown and then got confused that a thrown string didn't match. This test have easily been fixed by removing the `Error` (at least I assume so).\r\n\r\nWith the new `throw()` this test still fails with a rather cryptic error message (*Function threw exception that is not an error: \"...\"*) and now can't be easily fixed. The situation is not really improved, the user needs to implement their own `throw()` or refactor their library to work with the testing framework. Usually you would want it the other way around, having the tests first to support the refactoring.\r\n\r\nI don't think there is really a good reason to hard fail in non-`Error` values. To solve #1439 a clearer error message would be enough. It should be no problem to explicitly tell the user that the exception/rejection didn't have the specified type.\r\n\r\nAdditionally from the name one would expect `throws()` to just check for any thrown exceptions, not to fail when a wrong value is thrown."}}
{"actor":{"display_login":"sth"}}