{"action":"created","issue":{"url":"https://api.github.com/repos/wix/detox/issues/786","repository_url":"https://api.github.com/repos/wix/detox","labels_url":"https://api.github.com/repos/wix/detox/issues/786/labels{/name}","comments_url":"https://api.github.com/repos/wix/detox/issues/786/comments","events_url":"https://api.github.com/repos/wix/detox/issues/786/events","html_url":"https://github.com/wix/detox/pull/786","id":331793101,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0NDM3Njk3","number":786,"title":"Stack traces for failures now include caller's test code","user":{"login":"mikelovesrobots","id":9510,"node_id":"MDQ6VXNlcjk1MTA=","avatar_url":"https://avatars0.githubusercontent.com/u/9510?v=4","gravatar_id":"","url":"https://api.github.com/users/mikelovesrobots","html_url":"https://github.com/mikelovesrobots","followers_url":"https://api.github.com/users/mikelovesrobots/followers","following_url":"https://api.github.com/users/mikelovesrobots/following{/other_user}","gists_url":"https://api.github.com/users/mikelovesrobots/gists{/gist_id}","starred_url":"https://api.github.com/users/mikelovesrobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikelovesrobots/subscriptions","organizations_url":"https://api.github.com/users/mikelovesrobots/orgs","repos_url":"https://api.github.com/users/mikelovesrobots/repos","events_url":"https://api.github.com/users/mikelovesrobots/events{/privacy}","received_events_url":"https://api.github.com/users/mikelovesrobots/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-12T23:51:04Z","updated_at":"2018-06-13T19:36:03Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/wix/detox/pulls/786","html_url":"https://github.com/wix/detox/pull/786","diff_url":"https://github.com/wix/detox/pull/786.diff","patch_url":"https://github.com/wix/detox/pull/786.patch"},"body":"Thanks for making Detox. We use it quite a bit. Test failures can sometimes be hard to parse though, so this PR adds stack traces that include the caller's test code.\r\n\r\nFor comparison's sake, here's what a failure looks like on wix/detox (master):\r\n```\r\n    Error: Cannot find UI element.\r\n    Exception with Action: {\r\n      \"Action Name\" : \"Tap\",\r\n      \"Element Matcher\" : \"(((respondsToSelector(accessibilityIdentifier) && accessibilityID('LeftHeaderButtonxxx')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('LeftHeaderButtonxxx')) && kindOfClass('RCTScrollView'))))))\",\r\n      \"Recovery Suggestion\" : \"Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element.\"\r\n    }\r\n    \r\n    Error Trace: [\r\n      {\r\n        \"Description\" : \"Interaction cannot continue because the desired element was not found.\",\r\n        \"Error Domain\" : \"com.google.earlgrey.ElementInteractionErrorDomain\",\r\n        \"Error Code\" : \"0\",\r\n        \"File Name\" : \"GREYElementInteraction.m\",\r\n        \"Function Name\" : \"-[GREYElementInteraction matchedElementsWithTimeout:error:]\",\r\n        \"Line\" : \"124\"\r\n      }\r\n    ]\r\n      \r\n      at Client.execute (node_modules/detox/src/client/Client.js:74:13)\r\n```\r\n\r\nAnd with this branch:\r\n```\r\n    Error: Cannot find UI element.\r\n    Exception with Action: {\r\n      \"Action Name\" : \"Tap\",\r\n      \"Element Matcher\" : \"(((respondsToSelector(accessibilityIdentifier) && accessibilityID('LeftHeaderButtonxxx')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('LeftHeaderButtonxxx')) && kindOfClass('RCTScrollView'))))))\",\r\n      \"Recovery Suggestion\" : \"Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element.\"\r\n    }\r\n    \r\n    Error Trace: [\r\n      {\r\n        \"Description\" : \"Interaction cannot continue because the desired element was not found.\",\r\n        \"Error Domain\" : \"com.google.earlgrey.ElementInteractionErrorDomain\",\r\n        \"Error Code\" : \"0\",\r\n        \"File Name\" : \"GREYElementInteraction.m\",\r\n        \"Function Name\" : \"-[GREYElementInteraction matchedElementsWithTimeout:error:]\",\r\n        \"Line\" : \"124\"\r\n      }\r\n    ]\r\n\r\n       6 | export const signUpFlow = async (mailbox: TempMailbox) => {\r\n       7 |   // user can cancel the sign up process\r\n       8 |   await elementByPath('Landing/createAccount').tap()\r\n     > 9 |   await elementByPath('LeftHeaderButtonxxx').tap()\r\n      10 | \r\n      11 |   await expect(elementByPath('Landing/createAccount')).toBeVisible()\r\n      \r\n      at Client.execute (node_modules/detox/src/client/Client.js:73:28)\r\n      at InvocationManager.execute (node_modules/detox/src/invoke.js:11:33)\r\n      at ActionInteraction.execute (node_modules/detox/src/ios/expect.js:178:29)\r\n      at Element.tap (node_modules/detox/src/ios/expect.js:270:63)\r\n      at _callee$ (__e2e__/signUpFlow.ts:9:49)\r\n      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)\r\n      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)\r\n      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)\r\n      at fulfilled (node_modules/tslib/tslib.js:104:62)\r\n```"},"comment":{"url":"https://api.github.com/repos/wix/detox/issues/comments/397059363","html_url":"https://github.com/wix/detox/pull/786#issuecomment-397059363","issue_url":"https://api.github.com/repos/wix/detox/issues/786","id":397059363,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzA1OTM2Mw==","user":{"login":"mikelovesrobots","id":9510,"node_id":"MDQ6VXNlcjk1MTA=","avatar_url":"https://avatars0.githubusercontent.com/u/9510?v=4","gravatar_id":"","url":"https://api.github.com/users/mikelovesrobots","html_url":"https://github.com/mikelovesrobots","followers_url":"https://api.github.com/users/mikelovesrobots/followers","following_url":"https://api.github.com/users/mikelovesrobots/following{/other_user}","gists_url":"https://api.github.com/users/mikelovesrobots/gists{/gist_id}","starred_url":"https://api.github.com/users/mikelovesrobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikelovesrobots/subscriptions","organizations_url":"https://api.github.com/users/mikelovesrobots/orgs","repos_url":"https://api.github.com/users/mikelovesrobots/repos","events_url":"https://api.github.com/users/mikelovesrobots/events{/privacy}","received_events_url":"https://api.github.com/users/mikelovesrobots/received_events","type":"User","site_admin":false},"created_at":"2018-06-13T19:36:03Z","updated_at":"2018-06-13T19:36:03Z","author_association":"NONE","body":"This was a little hard to track down, what's going on is in `jest-message-util`, there's a function called `getTopFrame` inside `formatStackTrace` that decides which frame in the stack trace is worth highlighting, and it does that by skipping all the stack frames that have common things like \"node_modules\" or \"jest\" or \"<anonymous>.\" in the string (among others).  \r\n\r\nSo when a user of detox is running their tests, detox will be inside node_modules so it'll skip that and show the user's own code, but when you're running the detox package's tests, it's going to show you the top frame.\r\n\r\n* https://github.com/facebook/jest/blob/a1adaff21db93517e60be840303518490cd5d51f/packages/jest-message-util/src/index.js#L253\r\n"}}
{"actor":{"display_login":"mikelovesrobots"}}