{"action":"created","issue":{"url":"https://api.github.com/repos/chaijs/chai/issues/551","repository_url":"https://api.github.com/repos/chaijs/chai","labels_url":"https://api.github.com/repos/chaijs/chai/issues/551/labels{/name}","comments_url":"https://api.github.com/repos/chaijs/chai/issues/551/comments","events_url":"https://api.github.com/repos/chaijs/chai/issues/551/events","html_url":"https://github.com/chaijs/chai/pull/551","id":116932202,"number":551,"title":"Fixes an issues when both `.throws()` and `not.throws()` produce failures.","user":{"login":"jails","id":1306941,"avatar_url":"https://avatars.githubusercontent.com/u/1306941?v=3","gravatar_id":"","url":"https://api.github.com/users/jails","html_url":"https://github.com/jails","followers_url":"https://api.github.com/users/jails/followers","following_url":"https://api.github.com/users/jails/following{/other_user}","gists_url":"https://api.github.com/users/jails/gists{/gist_id}","starred_url":"https://api.github.com/users/jails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jails/subscriptions","organizations_url":"https://api.github.com/users/jails/orgs","repos_url":"https://api.github.com/users/jails/repos","events_url":"https://api.github.com/users/jails/events{/privacy}","received_events_url":"https://api.github.com/users/jails/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2015-11-14T15:13:51Z","updated_at":"2016-04-14T01:08:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/chaijs/chai/pulls/551","html_url":"https://github.com/chaijs/chai/pull/551","diff_url":"https://github.com/chaijs/chai/pull/551.diff","patch_url":"https://github.com/chaijs/chai/pull/551.patch"},"body":"This PR solves an issue when both `.throws()` and `not.throws()` produce failures. Exemple:\r\n```js\r\nexpect(function() { throw new Error(); }).to.throw(Error, 'hello'); // fails\r\nexpect(function() { throw new Error(); }).to.not.throw(Error, 'hello'); // fails too\r\n```\r\nImo the `not`spec above should pass.\r\n\r\nThis PR solves this issue and also modify the initial behavior by perfoming lazy comparison on exceptions to allows this syntax to make it works out of the box:\r\n```js\r\nexpect(function() { throw new Error('testing'); }).to.throw(new Error('testing')); \r\n```\r\nIndeed previoulsy a `===` comparison was made on objects which requires the following syntax:\r\n```js\r\nexpect(function() { throw new Error('testing'); }).to.throw(Error, 'testing'); \r\n```\r\nNow both syntax can be used either way. the only difference is one is assuming the error message to be strictly identical since the second way only requires `testing` to be included in the error message.\r\n\r\nSolves https://github.com/chaijs/chai/issues/436, https://github.com/chaijs/chai/issues/430 and probaly https://github.com/chaijs/chai/pull/470"},"comment":{"url":"https://api.github.com/repos/chaijs/chai/issues/comments/209708415","html_url":"https://github.com/chaijs/chai/pull/551#issuecomment-209708415","issue_url":"https://api.github.com/repos/chaijs/chai/issues/551","id":209708415,"user":{"login":"lucasfcosta","id":6868147,"avatar_url":"https://avatars.githubusercontent.com/u/6868147?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasfcosta","html_url":"https://github.com/lucasfcosta","followers_url":"https://api.github.com/users/lucasfcosta/followers","following_url":"https://api.github.com/users/lucasfcosta/following{/other_user}","gists_url":"https://api.github.com/users/lucasfcosta/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasfcosta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasfcosta/subscriptions","organizations_url":"https://api.github.com/users/lucasfcosta/orgs","repos_url":"https://api.github.com/users/lucasfcosta/repos","events_url":"https://api.github.com/users/lucasfcosta/events{/privacy}","received_events_url":"https://api.github.com/users/lucasfcosta/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T01:08:08Z","updated_at":"2016-04-14T01:08:08Z","body":"Hi @meeber, thanks for your feedback!\r\nThose features look really useful, but I'm not sure about introducing this kind syntax, it doesn't seem as fluid as the rest of our API. Currently, as `.throws` changes the assertion subject, you can chain other assertions and test things against the `Error` thrown, including checking the `stack`. You can see some tests that look like it at #661 (take a look at the test files).\r\n\r\nGiving a single `String`/`RegExp` argument to match only the error match, however, seems like an excellent idea, if @keithamus agrees I'd be happy to include it in the PR I'm working on, so lets hear his opinion.\r\n\r\nCurrently I'm working to move `checkError` into a separate module and make the `.throws` assertion simpler, as said on #457. I may finish it until the end of this weekend and then we can review and define features/behaviours in a more solid ground.\r\n\r\nThanks again for sharing your ideas! :smile: "}}