-
Notifications
You must be signed in to change notification settings - Fork 244
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
Bug: Options/data from mixins not available when using class components SFC #544
Comments
I think so, we have some simple tests here. What problem are you having? Can you try reproduce the problem in this code-base, perhaps? |
I forked this repo and added to the classComponent spec file here: https://github.com/Evertvdw/vue-test-utils-next/blob/class-component-mixin/tests/features/classComponent.spec.ts When you run the test you will see a warning that |
I see - passing Are you interested in debugging this? If so, the next step would be a test without an SFC, but instead using a render function. That would help narrow it down (eg, maybe the bug only happens for SFCs - that could mean a bug in |
@lmiller1990 I tried to debug it but I get stuck pretty quickly. Using a mixin with a render function works fine, so the issues seems to be with a SFC. I tried update to latest jest/ts-jest v26, just to be sure but that did not help either. I pushed changes to my forked repo, if you want to check it out: https://github.com/Evertvdw/vue-test-utils-next/blob/class-component-mixin/tests/features/classComponent.spec.ts I also tried using mixins like this: @Options({
mixins: [ClassMixin]
}) Which cause the created() hook to be called from the classMixin atleast (with Next step would be to deepdive in the |
@lmiller1990 I dug into it a bit deeper and my guess is that it is a if (
tempOutput.match(/\}\(.*.?Vue\);/) &&
tempOutput.includes('vue-class-component')
) {
node.add(`
;exports.default = {
...exports.default.__vccBase,
...exports.default.__vccOpts
};`)
} @Stijn98s You added the if statement, can you tell what the idea is behind this? I also added another test to my forked repo which fails, which is a SFC which extends from Vue but not Vue imported from @lmiller1990 Any chance you can dig into this? |
I added the if statement so the @lmiller1990 did a video on this when he was debugging https://www.youtube.com/watch?v=okQh9O61S-0 |
@Stijn98s As I have shown above, |
I found the issue and created a PR for the fix in |
I reviewed and merge the PR in vue-jest. Nice job figuring this out, I can release a new version of |
Thanks! My thoughts exactly on the string patching 😅 |
Is there currently support for using vue-test-utils together with
vue-class-components
? I am currently trying to get that to work and it works in part but when using mixins it does not. I have a hard time figuring out where to report this.The text was updated successfully, but these errors were encountered: