{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/4692","labels_url":"https://api.github.com/repos/facebook/react/issues/4692/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/4692/comments","events_url":"https://api.github.com/repos/facebook/react/issues/4692/events","html_url":"https://github.com/facebook/react/issues/4692","id":102646660,"number":4692,"title":"Error: Invariant Violation: findAllInRenderedTree(...): instance must be a composite component","user":{"login":"gajus","id":973543,"avatar_url":"https://avatars.githubusercontent.com/u/973543?v=3","gravatar_id":"","url":"https://api.github.com/users/gajus","html_url":"https://github.com/gajus","followers_url":"https://api.github.com/users/gajus/followers","following_url":"https://api.github.com/users/gajus/following{/other_user}","gists_url":"https://api.github.com/users/gajus/gists{/gist_id}","starred_url":"https://api.github.com/users/gajus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gajus/subscriptions","organizations_url":"https://api.github.com/users/gajus/orgs","repos_url":"https://api.github.com/users/gajus/repos","events_url":"https://api.github.com/users/gajus/events{/privacy}","received_events_url":"https://api.github.com/users/gajus/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-08-23T18:51:05Z","updated_at":"2015-12-08T21:53:07Z","closed_at":"2015-08-23T18:56:23Z","body":"I am writing a test case using Mocha and JSDom.\r\n\r\n```js\r\nimport React from 'react';\r\nimport TestUtils from 'react-addons-test-utils';\r\n\r\ndescribe('ReactOutsideEvent', () => {\r\n    it('captures mousedown event', () => {\r\n        let detachedCoponent;\r\n\r\n        detachedCoponent = TestUtils.renderIntoDocument(<div>\r\n            <div className='foo'></div>\r\n        </div>);\r\n\r\n        TestUtils.scryRenderedDOMComponentsWithClass(detachedCoponent, 'foo');\r\n    });\r\n});\r\n```\r\n\r\nI'd like to obtain a reference to the generated DOMNode with `className` \"foo\". `scryRenderedDOMComponentsWithClass` produces:\r\n\r\n```\r\nError: Invariant Violation: findAllInRenderedTree(...): instance must be a composite component\r\n```\r\n\r\nI have also tried `scryRenderedDOMComponentsWithTag` and got the same error.\r\n\r\nUsing 0.14.0-beta3."},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/163029873","html_url":"https://github.com/facebook/react/issues/4692#issuecomment-163029873","issue_url":"https://api.github.com/repos/facebook/react/issues/4692","id":163029873,"user":{"login":"vysinsky","id":3693578,"avatar_url":"https://avatars.githubusercontent.com/u/3693578?v=3","gravatar_id":"","url":"https://api.github.com/users/vysinsky","html_url":"https://github.com/vysinsky","followers_url":"https://api.github.com/users/vysinsky/followers","following_url":"https://api.github.com/users/vysinsky/following{/other_user}","gists_url":"https://api.github.com/users/vysinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/vysinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vysinsky/subscriptions","organizations_url":"https://api.github.com/users/vysinsky/orgs","repos_url":"https://api.github.com/users/vysinsky/repos","events_url":"https://api.github.com/users/vysinsky/events{/privacy}","received_events_url":"https://api.github.com/users/vysinsky/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T21:53:07Z","updated_at":"2015-12-08T21:53:07Z","body":"Hi, I've just found a solution which works for me:\r\n\r\nPrevious code which was failing on this error:\r\n```\r\nvar myComponent = TestUtils.renderIntoDocument(\r\n    <div>\r\n        <MyComponent page={page1} dispatch={dispatch}>Foo</MyComponent>\r\n\t<MyComponent page={page2} dispatch={dispatch}>Foo</MyComponent>\r\n    </div>\r\n);\r\n\r\nassert.equal(\r\n\tTestUtils.scryRenderedDOMComponentsWithTag(\r\n\t\tmyComponent,\r\n\t\t'a'\r\n\t).length,\r\n\t2\r\n);\r\n```\r\n\r\n(test checks that component is 'rerendered' after changing its state)\r\n\r\nCode which fixed that:\r\n```\r\nvar Wrapper = React.createClass({\r\n\trender: function() {\r\n\t\treturn (\r\n\t\t\t<div>\r\n\t\t\t\t{this.props.children}\r\n\t\t\t</div>\r\n\t\t);\r\n\t}\r\n});\r\n\r\nvar myComponent = TestUtils.renderIntoDocument(\r\n    <Wrapper>\r\n        <MyComponent page={page1} dispatch={dispatch}>Foo</MyComponent>\r\n\t<MyComponent page={page2} dispatch={dispatch}>Foo</MyComponent>\r\n    </Wrapper>\r\n);\r\n\r\nassert.equal(\r\n\tTestUtils.scryRenderedDOMComponentsWithTag(\r\n\t\tmyComponent,\r\n\t\t'a'\r\n\t).length,\r\n\t2\r\n);\r\n```\r\n\r\nAs `Wrapper` is normal React component it does not fail anymore. Hope it will help you :)"}}