-
Notifications
You must be signed in to change notification settings - Fork 668
injected router not passed to child-components #753
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
Thanks for the detailed bug report! The issue is that child extended components need to be extended, and this wasn't being done for parent extended components. This should be fixed in #757 |
@eddyerburgh I updated to beta.21 The problem still persists, there is an additional error-message now:
I do not understand, what the first message is trying to say me, though :/ Any pointers? |
Your original issue was fixed in #757, but in your example you need to pass the localVue constructor: it('renders props.msg when passed', () => {
const localVue = createLocalVue();
localVue.use(VueRouter);
mount(HelloWorld, {
router: new VueRouter(),
localVue,
});
}); This is because Vue Router adds properties to the Vue constructor that it is installed on. For child Vue components to include the properties, they need to be constructed using the constructor with the installed plugins. To do that in Vue Test Utils, you pass the constructor in the The message that you are receiving was part of the fix. It is intended to warn you that the child component has been extended internally by Vue Test Utils. This means you can no longer use a component selector to Note that the fix is only for immediate children. There is still an issue with nested extended children, which will be fixed in #840. |
Damn, the missing Thank you for taking the time for a detailed response :) |
Yeah, I'm not sure if it's possible to maybe enhance the language in the error reported in this case, but I ran into a similar problem, where I forgot to create a localvue instance and provide mocks for the $route, and so I got this: And unless you remember that you're accessing the "query" property on the $route instance in your component, it's a very befuddling error. It would be nicer if it were possible to show the code from the actual component class, not the script src reference. Then I might have actually realized it's giving me the exact line number I needed to realize my error:
|
Version
1.0.0-beta.20
Reproduction link
https://github.com/doppelreim/vue-test-app/tree/test-route-in-child
Steps to reproduce
Run
./node_modules/.bin/vue-cli-service test:unit
What is expected?
The router-mock used in
mount
should be available in the child-component.What is actually happening?
It is not available.
Error:
My best guess is, that the injected routerMock is visible only in the component under test, and it is somehow not visible in the child-component?
This is the same as #591 and #679. Those tickets were closed, but the issue still persists and I can not reopen them.
The text was updated successfully, but these errors were encountered: