react: Error: Invariant Violation: findAllInRenderedTree(...): instance must be a composite component

I am writing a test case using Mocha and JSDom.

import React from 'react';
import TestUtils from 'react-addons-test-utils';

describe('ReactOutsideEvent', () => {
    it('captures mousedown event', () => {
        let detachedCoponent;

        detachedCoponent = TestUtils.renderIntoDocument(<div>
            <div className='foo'></div>
        </div>);

        TestUtils.scryRenderedDOMComponentsWithClass(detachedCoponent, 'foo');
    });
});

I’d like to obtain a reference to the generated DOMNode with className “foo”. scryRenderedDOMComponentsWithClass produces:

Error: Invariant Violation: findAllInRenderedTree(...): instance must be a composite component

I have also tried scryRenderedDOMComponentsWithTag and got the same error.

Using 0.14.0-beta3.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 3
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Yes, this is a breaking change and you’ll need to change your tests to be different, sorry. See 4070c4ca20b1d08a00fe278d561642e87373c09f. detachedCoponent is actually a DOM node now so the test utils can’t look into it to find the React component tree any more. This rarely comes up because you’ll almost always be testing your own components (it’s our job to test that the DOM components work, not yours 😃).