-
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
RouterLinkStub doesn't seem to supports new slot api? #1803
Comments
Seems like a bug - probably need to dive into the RouterStub and see what's going on. |
Same here. I'm using the new slot api to create custom behaviour. So in the meanwhile I extended the router-stub for my purposes to something like this. You may need to add import { RouterLinkStub } from '@vue/test-utils'
// ...
const stubs = {
RouterLink: {
...RouterLinkStub,
render() {
return this.$scopedSlots.default({
href: this.to,
navigate: jest.fn(),
isActive: false
})
}
}
} |
Sorry guys, all my time is spent on VTU v2 and Vue Jest lately. I wonder if #1877 will fix this? Did anyone get to look at this? Happy to give some pointers, I'd love to see this fixed but I can't look at it right now. |
As of today, in 1.3.4, this is not working. |
@BrevAlessio I think that you can't expect it to be fixed in VTU1 ( sadly ). Based on the last comments from @lmiller1990 in #1564 (comment) . So Lachlan, Can I mark this PR as |
I think this is actually pretty easy to fix, we'd just need to rework https://github.com/vuejs/vue-test-utils/blob/dev/packages/test-utils/src/components/RouterLinkStub.js to do whatever the OP wants - this is kind of different from the others stubs, since we ship a specific implementation, that's apparently out of date. |
Ok, then I can have a look once I'm back |
Subject of the issue
I'm testing a Tab handler component. It's highly coupled with
router-link
. Since v3.1.0 it's recommended to use the slot api to handle complex templates.I have to test the behavior of my logic wich depends on
isActive
andisExactActive
slot props.Currently the
RouterLinkStub
component doesn't work with the slot api.Steps to reproduce
components/ToTest.vue
tests/ToTest.spec.js
Expected behaviour
The RouterLinkStub component should render the content of the slot. Wich is with the exemple:
Actual behaviour
The component renders:
Possible Solution
Rewrite the RouterLinkStub component to support the
custom
props and theslot
apiThe text was updated successfully, but these errors were encountered: