You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the router mock as it currently is, we cannot test the prop changing functionality (described here in the vue docs).
More specifically to my situation: I have two routes that load the same component with a different prop, and the component itself contains links to both routes. I want to test some functionality that happens when the prop changes. I'd like to keep it as close to real use as possible, and in a real use situation the flow of events would go something like User clicks link -> vue-router pushes the given route -> vue-router updates the component's prop -> a watcher is triggered. I could easily use VTU's setProps function, but that would skip the first two steps, which isn't ideal.
Proposed solution
When I use the mocked router's push function, I would like for it to update the current component's props if there is a props option given in the route.
In order to not break existing code this could be added as an option similar to runInComponentGuards, which would be disabled by default.
Describe alternatives you've considered
As I stated above it's easy enough to use setProps, but that adds another step away from real use.
The text was updated successfully, but these errors were encountered:
From the outside it looks like you want to test vue-router itself. While that might have some utility in an e2e test, you should probably limit your unit tests to the components' inputs and outputs. That's what UTs are for.
Note you also have router.setQuery and router.setParams helpers available on the mock instance, allowing you to test any watchers set on route.
It's more so that I want to test behavior triggered by vue-router's functionality. You're right that it falls somewhat outside the scope of a unit test, but the tests that I'm writing aren't strict unit tests (it gets very hard to stick to straight unit testing when trying to test whole pages I've found).
I will check out the setQuery and setParams functions, hopefully one of those will help me get the functionality I need! Thanks
What problem is this solving
When using the router mock as it currently is, we cannot test the prop changing functionality (described here in the vue docs).
More specifically to my situation: I have two routes that load the same component with a different prop, and the component itself contains links to both routes. I want to test some functionality that happens when the prop changes. I'd like to keep it as close to real use as possible, and in a real use situation the flow of events would go something like User clicks link -> vue-router pushes the given route -> vue-router updates the component's prop -> a watcher is triggered. I could easily use VTU's
setProps
function, but that would skip the first two steps, which isn't ideal.Proposed solution
When I use the mocked router's
push
function, I would like for it to update the current component's props if there is a props option given in the route.In order to not break existing code this could be added as an option similar to
runInComponentGuards
, which would be disabled by default.Describe alternatives you've considered
As I stated above it's easy enough to use
setProps
, but that adds another step away from real use.The text was updated successfully, but these errors were encountered: