-
Notifications
You must be signed in to change notification settings - Fork 47.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Invariant Violation: findAllInRenderedTree(...): instance must be a composite component #4692
Comments
Yes, this is a breaking change and you'll need to change your tests to be different, sorry. See 4070c4c. |
Awesome. Thank you. |
@spicyj So how would we now test that say after clicking something the class of a div has been updated to hide inside one of our components? Is that something we shouldn't be testing? |
@benhughes Can you paste a sample test so I can see what you mean? |
@benhughes just come across this myself. I've started accessing them as though they were DOM nodes after seeing this SO answer. So for your example expect(myDiv.className).toContain('hide'); |
@sheepsteak That sounds like a different warning, but I'm glad you got it to work. |
You're right, I was searching for two problems at once! My answer above relates to this warning:
|
This has caused trouble on some of my tests (and I can see people who have mentioned this ticket with the same problem). I was using nested calls to the selector functions to find the components I was interested in: const sections = TestUtils.scryRenderedDOMComponentsWithTag(myPage, 'section');
expect(sections.length).to.eq(3)
const headers = sections.map(section => {
return TestUtils.findRenderedDOMComponentWithTag(section, 'h1').props.children;
}); It looks like now this is no longer possible, and I don't really see an alternative in the test utils that's functionally equivalent. |
Hi @iangreenleaf, I've just found a solution which works for me: Previous code which was failing on this error:
(test checks that component is 'rerendered' after changing its state) Code which fixed that:
As |
@iangreenleaf Did you find a solution to the nested lookup issue? I'm stuck with exactly that. @spicyj Is there any way to do a nested lookup? More specifically, as @iangreenleaf mentioned, I'd like to do:
But, TestUtils complains:
|
I have same issue, with |
@moroshko Nope 😿 Our solution is to find a different tool, and abandon TestUtils for all but the most low-level unit tests. |
@iangreenleaf What tool did you end up with? |
@moroshko Haven't settled on anything yet, but we'll probably be looking for something more integration-oriented that works with the real DOM and XPath/CSS-style selectors. For the moment we're just sticking with Capybara (since we are already running Ruby). The limited scope of TestUtils is fine for testing individual components, but is unwieldy when actually simulating user interactions. |
I have not tried https://github.com/airbnb/enzyme but it looks promising. |
I am writing a test case using Mocha and JSDom.
I'd like to obtain a reference to the generated DOMNode with
className
"foo".scryRenderedDOMComponentsWithClass
produces:I have also tried
scryRenderedDOMComponentsWithTag
and got the same error.Using 0.14.0-beta3.
The text was updated successfully, but these errors were encountered: