{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/10265","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/10265/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/10265/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/10265/events","html_url":"https://github.com/facebook/react-native/pull/10265","id":181276414,"number":10265,"title":"Snapshot Delay in SnapshotViewIOS","user":{"login":"kgowru","id":3108072,"avatar_url":"https://avatars.githubusercontent.com/u/3108072?v=3","gravatar_id":"","url":"https://api.github.com/users/kgowru","html_url":"https://github.com/kgowru","followers_url":"https://api.github.com/users/kgowru/followers","following_url":"https://api.github.com/users/kgowru/following{/other_user}","gists_url":"https://api.github.com/users/kgowru/gists{/gist_id}","starred_url":"https://api.github.com/users/kgowru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kgowru/subscriptions","organizations_url":"https://api.github.com/users/kgowru/orgs","repos_url":"https://api.github.com/users/kgowru/repos","events_url":"https://api.github.com/users/kgowru/events{/privacy}","received_events_url":"https://api.github.com/users/kgowru/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7"},{"url":"https://api.github.com/repos/facebook/react-native/labels/GH%20Review:%20review-needed","name":"GH Review: review-needed","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-10-05T21:57:02Z","updated_at":"2016-10-07T22:50:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/react-native/pulls/10265","html_url":"https://github.com/facebook/react-native/pull/10265","diff_url":"https://github.com/facebook/react-native/pull/10265.diff","patch_url":"https://github.com/facebook/react-native/pull/10265.patch"},"body":"**Explain the motivation for making this change. What existing problem does the pull request solve?**\r\n\r\nThis PR incorporates the ability to add a snapshotDelay to SnapshotViewIOS. I found the Snapshot Image comparison tests to be insanely useful. It adds capabilities that component tests just can't compare to. But, I have noticed the snapshot tests do not work well in views where there are animations after mounting. The snapshot compares the image instantly. The fix is simple, just pass in a `snapshotDelay` prop into SnapshotViewIOS. The delay specifies the number of seconds to wait before comparing the image to your goldfile image.\r\n\r\n**Test plan (required)**\r\n\r\nThe tests all have passed as expected (iOS test, npm test, and linter).\r\n\r\n**Code formatting**\r\n\r\nAll code is formatted but I think the way I’m implementing the wait might be able to be improved:\r\n\r\n```\r\ndispatch_async(dispatch_get_main_queue(), ^{\r\n      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, self.snapshotDelay * NSEC_PER_SEC),dispatch_get_main_queue(), ^{\r\n        if (self.onSnapshotReady) {\r\n          self.onSnapshotReady(@{@\"testIdentifier\" : self.testIdentifier});\r\n        }\r\n      });\r\n    });\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/252379263","html_url":"https://github.com/facebook/react-native/pull/10265#issuecomment-252379263","issue_url":"https://api.github.com/repos/facebook/react-native/issues/10265","id":252379263,"user":{"login":"kgowru","id":3108072,"avatar_url":"https://avatars.githubusercontent.com/u/3108072?v=3","gravatar_id":"","url":"https://api.github.com/users/kgowru","html_url":"https://github.com/kgowru","followers_url":"https://api.github.com/users/kgowru/followers","following_url":"https://api.github.com/users/kgowru/following{/other_user}","gists_url":"https://api.github.com/users/kgowru/gists{/gist_id}","starred_url":"https://api.github.com/users/kgowru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kgowru/subscriptions","organizations_url":"https://api.github.com/users/kgowru/orgs","repos_url":"https://api.github.com/users/kgowru/repos","events_url":"https://api.github.com/users/kgowru/events{/privacy}","received_events_url":"https://api.github.com/users/kgowru/received_events","type":"User","site_admin":false},"created_at":"2016-10-07T22:50:42Z","updated_at":"2016-10-07T22:50:42Z","body":"Well you could in fact do this:\r\n```\r\nimport {NativeModules} from react-native;\r\nvar TestModule = NativeModules.TestModule;\r\n. . .\r\n<SnapshotViewIOS onSnapshotReady={()=>{setTimeout(TestModule.verifySnapshot(TestModule.markTestPassed), 100);}}>\r\n<UIExplorerExampleContainer module={ExampleModule} />\r\n</SnapshotViewIOS>\r\n. . .\r\n```\r\n\r\nBut I think it's cleaner if it was passed into the prop as a delay so you don't have to import NativeModules in your wrapper component and all of the testing is encapsulated in <SnapshotViewIOS/>. \r\n"}}
{"actor":{"display_login":"kgowru"}}