-
Notifications
You must be signed in to change notification settings - Fork 668
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
fix: wrap extended child components #840
Conversation
`to ensure it has the correct instance properties. ` + | ||
`This means it is not possible to find the component ` + | ||
`with a component selector. To find the component, ` + | ||
`you must stub it manually using the stubs mounting ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't find({ name: 'foo' })
still work in this case? If so maybe that should be added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would, I'll add it.
This PR also makes your suggestion of searching by string name a lot more attractive, as it would solve this problem entirely 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice 👍 Lately I (and my team) have decided on the following practice:
- when finshing HTML elements, using the
querySelector
API - when finding components, use the
find(Component)
API.
which I think is the most intuitive for onboarding people new to Vue and TDD.
@@ -389,8 +389,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { | |||
AsyncComponent: () => import('~resources/components/component.vue') | |||
} | |||
} | |||
const wrapper = shallowMount(TestComponent) | |||
expect(wrapper.find({ name: 'AsyncComponent' }).exists()).to.equal(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @eddyerburgh , sorry for commenting on such an old PR.
I was wondering why is the assertion for dynamic imports on shallowMount
were removed? Seems like I cannot simply handles component as dynamic import with shallowMount
anymore 🤔
Fixes #819
Fixes #790
For localVue to work we set Vue._base to be the localVue instance, so that component constructors are created by extending the localVue constructor with component options.
This is not the case for child components already extended with Vue.extend. Because they are already Vue constructors, they aren't extended from the localVue constructor. To fix this, we need to extend each extended component manually.
Previously we only replaced root components, with this PR we will overwrite nested extended components.
CC @lmiller1990