vue-test-utils: Can't find functional component
Hi there,
I found that find can’t get functional component.
For instance:
import { mount } from 'vue-test-utils'
import functionalComponent from './functionalComponent'
import ParentComponent from './ParentComponent'
const wrapper = mount(ParentComponent);
wrapper.find(functionalComponent); // Can't find it
I know that functional component is instanceless, so it’s understandable that wrapper can’t find it directly. However, that is really hard to test. One way is use ref to mark component but that is not ease-to-use when using multiple functional components in the same time.
Any suggestions to test functional component? Otherwise, how do you think about supporting finding functional component?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 18 (11 by maintainers)
This issue is still here in v31
Yes im using
wrapper.find({ name: 'aa-header' })for example. Where aa-header is the name of the functional component.My current workaround is to just add a class or id to the component and find it that way.
This should be reopened
One work around is: