{"action":"created","issue":{"url":"https://api.github.com/repos/chaijs/chai/issues/355","labels_url":"https://api.github.com/repos/chaijs/chai/issues/355/labels{/name}","comments_url":"https://api.github.com/repos/chaijs/chai/issues/355/comments","events_url":"https://api.github.com/repos/chaijs/chai/issues/355/events","html_url":"https://github.com/chaijs/chai/issues/355","id":55973712,"number":355,"title":"doesNotThrow swallows stacktrace info","user":{"login":"olsonpm","id":5957709,"avatar_url":"https://avatars.githubusercontent.com/u/5957709?v=3","gravatar_id":"","url":"https://api.github.com/users/olsonpm","html_url":"https://github.com/olsonpm","followers_url":"https://api.github.com/users/olsonpm/followers","following_url":"https://api.github.com/users/olsonpm/following{/other_user}","gists_url":"https://api.github.com/users/olsonpm/gists{/gist_id}","starred_url":"https://api.github.com/users/olsonpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olsonpm/subscriptions","organizations_url":"https://api.github.com/users/olsonpm/orgs","repos_url":"https://api.github.com/users/olsonpm/repos","events_url":"https://api.github.com/users/olsonpm/events{/privacy}","received_events_url":"https://api.github.com/users/olsonpm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chaijs/chai/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-29T23:32:45Z","updated_at":"2015-02-02T04:22:59Z","closed_at":null,"body":"Given a method that possibly throws an exception, I get the following stacktrace by wrapping it inside doesNotThrow:\r\n\r\n```\r\nAssertionError: expected [Function] to not throw an error but 'AssertionError: expected [<...>] to be a function' was thrown\r\nat Context.<method> (<file>:<line>:<char>)\r\n```\r\n\r\nif I just run the function without wrapping it\r\n```\r\n<Class> <method>:\r\nAssertionError: expected [<...>] to be a function\r\n  at <Class>.<method> (<file>:<line>:<char>) <----------This line is missing from above\r\n  at <Context>.<method> (<file>:<line>:<char>)\r\n```"},"comment":{"url":"https://api.github.com/repos/chaijs/chai/issues/comments/72404767","html_url":"https://github.com/chaijs/chai/issues/355#issuecomment-72404767","issue_url":"https://api.github.com/repos/chaijs/chai/issues/355","id":72404767,"user":{"login":"dasilvacontin","id":1260830,"avatar_url":"https://avatars.githubusercontent.com/u/1260830?v=3","gravatar_id":"","url":"https://api.github.com/users/dasilvacontin","html_url":"https://github.com/dasilvacontin","followers_url":"https://api.github.com/users/dasilvacontin/followers","following_url":"https://api.github.com/users/dasilvacontin/following{/other_user}","gists_url":"https://api.github.com/users/dasilvacontin/gists{/gist_id}","starred_url":"https://api.github.com/users/dasilvacontin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dasilvacontin/subscriptions","organizations_url":"https://api.github.com/users/dasilvacontin/orgs","repos_url":"https://api.github.com/users/dasilvacontin/repos","events_url":"https://api.github.com/users/dasilvacontin/events{/privacy}","received_events_url":"https://api.github.com/users/dasilvacontin/received_events","type":"User","site_admin":false},"created_at":"2015-02-02T04:22:59Z","updated_at":"2015-02-02T04:22:59Z","body":"I see what happened. The output is actually correct. I reproduced it with this simple code:\r\n```\r\nrequire('chai').should()\r\n\r\nvar f = function throwingFunction() {\r\n    throw new Error\r\n}\r\n\r\nf.should.not.throw() // comment this line\r\nf()\r\n```\r\nIn the first case you are seeing the stack trace of the AssertionError, which is generated (in my case) when executing `.throw()`.\r\n\r\nIn the second case you are seeing the stack trace of the actual error thrown by the tested function.\r\n\r\nI believe that showing the stack trace of the actual thrown error would be more useful, since you are also getting info about where the actual error was thrown.\r\n\r\nIf you want to change this behaviour, I'd be willing to prepare a PR. Cheers!"}}