-
Notifications
You must be signed in to change notification settings - Fork 276
Closed
Labels
Description
Will probably rely on #3. I have some ideas on how to handle this.
Instead of shallowMount, I think we should have a shallow mounting option (discussed internally).
const Comp = mount({
shallow: true
})How this should work
shallowMount was pretty buggy in VTU beta. It should completely stub out and child components. So:
<template>
<div>Content</div>
<Foo />
<Bar>
<div>BAR</div>
</Bar>
</template>Should render as follows when using shallow:
<div>Content</div>
<foo-stub />
<bar-stub />Whether it's <FooStub /> or <foo-stub> /> doesn't matter, the point is that the components are no longer rendered, nor is any of their code executed.
Things to consider:
- should a user be able to
finda stubbed out component? Feels a bit weird to try and find a component that is purposefully NOT rendered. But it might be a common use case - current
finddoes not supportfind(Component)syntax. I'm not sure it should - it was impossiblefind. One such issue: Some stubbed Vuetify components can't be found withfindwrapper method vue-test-utils#1272 and - consider this use case Can't trigger event of child component vue-test-utils#1410 people often stub out components then want to emit an event from them. Can we handle this better?