{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/react/issues/7371","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/7371/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/7371/comments","events_url":"https://api.github.com/repos/facebook/react/issues/7371/events","html_url":"https://github.com/facebook/react/issues/7371","id":168255251,"number":7371,"title":"ReactTestRenderer doesn't work with refs or ReactDOM.findDOMNode","user":{"login":"ryanseddon","id":143402,"avatar_url":"https://avatars.githubusercontent.com/u/143402?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanseddon","html_url":"https://github.com/ryanseddon","followers_url":"https://api.github.com/users/ryanseddon/followers","following_url":"https://api.github.com/users/ryanseddon/following{/other_user}","gists_url":"https://api.github.com/users/ryanseddon/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanseddon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanseddon/subscriptions","organizations_url":"https://api.github.com/users/ryanseddon/orgs","repos_url":"https://api.github.com/users/ryanseddon/repos","events_url":"https://api.github.com/users/ryanseddon/events{/privacy}","received_events_url":"https://api.github.com/users/ryanseddon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-29T05:47:05Z","updated_at":"2016-07-29T05:47:05Z","closed_at":null,"body":"Jest snapshot testing uses ReactTestRenderer but if my component contains a ref or uses `ReactDOM.findDOMNode` it throws `TypeError: component.getPublicInstance is not a function`.\r\n\r\n## Component\r\n\r\n```js\r\nimport React from 'react';\r\n\r\nexport default class Link extends React.Component {\r\n  render() {\r\n    return (\r\n      <a\r\n        ref={a => this._a = a}\r\n        href={this.props.page || '#'}>\r\n        {this.props.children}\r\n      </a>\r\n    );\r\n  }\r\n}\r\n```\r\n\r\n## Test \r\n\r\n```js\r\n'use strict'\r\n\r\nimport React from 'react';\r\nimport Link from '../Link';\r\nimport renderer from 'react/lib/ReactTestRenderer';\r\n\r\ndescribe('Link', () => {\r\n  it('renders correctly', () => {\r\n    const tree = renderer.create(\r\n      <Link page=\"foo\" />\r\n    ).toJSON();\r\n\r\n    expect(tree).toMatchSnapshot();\r\n  });\r\n});\r\n```\r\n\r\n## stack trace\r\n\r\n```bash\r\n FAIL  __tests__/Link-test.js (2.148s)\r\n● Link › it renders correctly\r\n  - TypeError: component.getPublicInstance is not a function\r\n        at attachRef (node_modules/react/lib/ReactRef.js:20:19)\r\n        at Object.ReactRef.attachRefs (node_modules/react/lib/ReactRef.js:42:5)\r\n        at attachRefs (node_modules/react/lib/ReactReconciler.js:26:12)\r\n        at CallbackQueue._assign.notifyAll (node_modules/react/lib/CallbackQueue.js:67:22)\r\n        at ReactTestReconcileTransaction.ON_DOM_READY_QUEUEING.close (node_modules/react/lib/ReactTestReconcileTransaction.js:37:26)\r\n        at ReactTestReconcileTransaction.Mixin.closeAll (node_modules/react/lib/Transaction.js:204:25)\r\n        at ReactTestReconcileTransaction.Mixin.perform (node_modules/react/lib/Transaction.js:151:16)\r\n        at batchedMountComponentIntoNode (node_modules/react/lib/ReactTestMount.js:61:27)\r\n        at ReactDefaultBatchingStrategyTransaction.Mixin.perform (node_modules/react/lib/Transaction.js:138:20)\r\n        at Object.ReactDefaultBatchingStrategy.batchedUpdates (node_modules/react/lib/ReactDefaultBatchingStrategy.js:63:19)\r\n```\r\n"}}
{"actor":{"display_login":"ryanseddon"}}