When stubbing a child component like:
wrapper = shallowMount(ComponentUnderTest, {
stubs: ['StringComponent'],
});
It is not possible to find the stubbed component using wrapper.find({ name: 'StringComponent' }) because it does not have a name.
In my case, I am stubbing an input component, and want to simulate it emitting an event in order to test the response in the parent component.
It looks like this could be a simple change in https://github.com/vuejs/vue-test-utils/blob/dev/packages/create-instance/create-component-stubs.js#L90
if (!componentOptions.name) {
componentOptions.name = name;
}
In my own testing this has been working fine, but I'm not familiar enough with the code yet to know if there might be any side-effects from this so I wanted to raise the issue before creating a PR.
@eddyerburgh i think this makes much sense. I dont see a reason not to do it?
Most helpful comment
@eddyerburgh i think this makes much sense. I dont see a reason not to do it?