-
Notifications
You must be signed in to change notification settings - Fork 668
Clarify docs on how to mock $root #1437
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
I don't think I think a PR adding a note about |
@lmiller1990 Irrespective of that, I see the "Mounting Options" documentation covering all possible cases when you need to provide/mock some of the component data (arguments, data, methods, slots, components, etc.). I might agree that the need in mocking I try prepare the PR, if I have time |
@aantipov I agree, everyone has different backgrounds - I can see why you might expect Will mark this as "good first issue" so someone else can pick it up if you don't have time. Thanks! |
Clarify how to mock $root fix vuejs#1437
What problem does this feature solve?
The docs say that I can use
mocks
mounting option to mock "global injections" like$route
.I considered
$root
as a "global injection" and that I can usemocks
to mock it. Unfortunately it didn't work for me, I spent lots of time trying to make it working, without any success. In the end I came up with a solution to useparentComponent
option to mock$root
.As far as I understood it's not possible to mock
$root
usingmocks
and it's not considered as a bug.If I'm right, then the docs for
mocks
need clarification stating that clearly and providing a way to mock$root
What does the proposed API look like?
The docs should say smth like this:
"One can't use
mocks
to mock$root
though. If you need to mock$root
, use "parentComponent" option instead."And provide "parentComponent" section with an example how to mock
$root
The text was updated successfully, but these errors were encountered: