-
Notifications
You must be signed in to change notification settings - Fork 665
Cannot call .findComponent() on wrapper of .find() result #1644
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
Comments
I can't remember exactly why but I think there is a architectural reason for why this doesn't work (difficult/impossible to implement without significant risk/breaking changes maybe? Could be wrong). It was briefly discussed here but with no real conclusion. If you are extremely motivated, you can attempt to remove the warning and see what happens. Most of the time, I just recommend people search for they want directly, by adding a |
I would encourage to make this work for VTU 2 first, before removing the warnings, they were added because the API is not backwards compatible. You cannot search for components from a dom node. |
@dobromir-hristov Where is VTU 2? I don't see any reference to it anywhere in this repo? Regardless, I'll trust that it won't work in VTU 2. Is there any way to find a component that's below a DOM node that matches a particular CSS selector? The reason I'm trying to do |
VTU next: https://github.com/vuejs/vue-test-utils-next For reference, implementing |
If it's that challenging to implement I'll just close this issue. I have yet to run into a scenario where finding a component below a specific DOM node is absolutely necessary, so I'm okay for now. Thanks for the help! |
Subject of the issue
I'm trying to use
.find()
then.findComponent()
on the wrapper returned by.find()
but I'm getting the error'You cannot chain findComponent off a DOM element. It can only be used on Vue Components.'
.Steps to reproduce
Expected behaviour
wrapper.findComponent(MyButton)
should find theMyButton
component.Actual behaviour
This error is thrown:
Possible Solution
I commented out these lines and it found the component just fine:
vue-test-utils/packages/test-utils/src/wrapper.js
Lines 240 to 244 in ea2a571
I'm not sure why this error exists, but it seems unnecessary in this case.
The text was updated successfully, but these errors were encountered: