-
Notifications
You must be signed in to change notification settings - Fork 668
Cannot stub sub-child-component on mounted #682
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 think this is similar to this other issue #649 At the moment, stubs only works on the I generally find using Is there a particular reason you can't use |
I agree with you about the ´dive ´
However using ´mount ´ in the snapshot test of the main components will
generate a lot of noise while editing a sub-...-sub-sub-component. Because
you will have to update the snapshots of all the parents, grand parents,
..., and grand-...-grand-parents.
For now, I agree with you. We can’t do better than ´mount ´but I hope
solving this bug will change that.
|
imho, <Header/>
<Body>
<LazyLoaded/>
<Cards>
<Card/>
.....
</Cards>
</Body>
<Footer/> I'd like to stub only LazyLoaded because I am not interested into it, and I'd like the snapshots rendering the whole tree except LazyLoaded (because of something I don't really care)... |
Maybe I am not using snapshots correctly, but to me, snapshots should capture the entire dom as rendered, aka actual If you want to make sure const wrapper = shallowMount(Foo)
expect(wrapper.find({ name: "Body" }).exists()).toBe(true)
expect(wrapper.find({ name: "Cards" }).exists()).toBe(true)
expect(wrapper.findAll({ name: "Card" })).toHaveLength(4) This kind of test makes it much more clear what should and shouldn't exist that a snapshot test. If one of the components suddenly disappears you will get an error like " should exists, but doesn't" instead of having to manually compare two snapshots and try to figure out what's going on. Instead of going out of your way to avoid testing something you don't care about, just focus on testing what you do care about. |
Whatever your preference for snapshot tests, this is a bug that we'll fix |
Version
1.0.0-beta.16
Reproduction link
https://codesandbox.io/s/9z96nkvyor
Steps to reproduce
My TestComponent has a ChildComponent that I want to test (to add in my snapshot, because it's a slot template)
My ChildComponent contains an AppHeader, that I want to stub (so my snap should not depend on it)
I am mounting with some stubs:
But the AppHeader is not stubbed in my test
What is expected?
I expect to generate a component with sub-component that can be stubbed
What is actually happening?
Sub-component are not stubbed
The text was updated successfully, but these errors were encountered: