-
Notifications
You must be signed in to change notification settings - Fork 723
docs(vue): update faq for Vue Router abstract mode #881
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
docs(vue): update faq for Vue Router abstract mode #881
Conversation
}) | ||
``` | ||
|
||
2. **Reset the window location `afterEach`**. If you don't want to pass an |
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.
This isn't the best option for people - they should instead use abstract
mode, so don't recommend it.
|
||
// Unlike the router in `hash` mode, the initial routing stack is empty. So, | ||
// you need to push an initial route to the stack. | ||
await router.push('/') |
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.
cc @maxarndt - this adds the initial push
you mentioned in testing-library/vue-testing-library#210 (comment)
2. **Reset the window location `afterEach`**. If you don't want to pass an | ||
instantiated Router, you can instead reset the `window.location` after each | ||
test, like this: | ||
To reduce boilerplate, you can create a custom render function to use throughout |
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.
@maxarndt - if you've got some time for a contribution, it would be great to pull over the Custom Render setup guide from the react-testing-library docs (https://testing-library.com/docs/react-testing-library/setup#custom-render) to the currently blank setup page of Vue Testing Library (https://testing-library.com/docs/vue-testing-library/setup). Then, we could link to the custom render docs from this FAQ.
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.
LGTM! We can work on the custom render section in a upcoming PR.
thanks and nice catch!
This update is in response to a conversation between @maxarndt and I here. The workaround of resetting
window.location
has some pitfalls, so this PR updates the documentation to only recommend usingabstract
mode.