-
Notifications
You must be signed in to change notification settings - Fork 668
this.$t is not a function in a class component #1767
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 am not sure how vue-class-component works under the hood - we just mutate I didn't even know you could access |
@lmiller1990
For me, this seems quite normal. Without using VCC you can write code like this:
|
I also have the same problem. The only thing I see this would work is to have a base class and a constrcutor for the global functions like public constructor() {
super();
this.$t = implemntation;
} and let the child Components extend it from there What i get as a error when I try to access this.$t is __this.$t is not defined |
^ good work around - I think we need something in VCC to make this work with test utils... |
I guess this is something which needs to be fixed in It also happens when you access |
If you can reproduce this in VCC without Test Utils, definitely post an issue there. |
#1815 (comment) was relevant for me |
i m facing some issue . is there any update for that ? |
There is no obvious fix we can do in VTU, from waht what I can see. Aside from adding some code in Vue Class Component to support this kind of behavior, which is not a library I work on or use, so I don't see this getting solved in the foreseeable future. |
Hi i'm facing this too. |
No update and unlikely this will be fixed - Vue Class Component seems deprecated, and I don't think we can fix this here, anyway -- it would be in that repo. See my post here: #1767 (comment) If someone wants to try fixing it, that'd be great, but I won't be working on this at this point. |
Subject of the issue
I have the following component
and the following unit test
When running this unit test, it fails with the following error:
Steps to reproduce
Just run unit tests in this project:
i18n-test.zip
Expected behaviour
Error
this.$t is not a function
should not occur. The$t
function is mocked.Actual behaviour
An error
this.$t is not a function
is thrown.Additional context
If I convert
someData
to computed property, like this:the error is gone.
The text was updated successfully, but these errors were encountered: