ionic-framework: bug: vue jest utils, shallowMount does not work when property values are symbols
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
Current Behavior
After bumping Ionic Vue from v5 to v6 RC, all my tests that are shallowMounted fail with the following error:
Expected Behavior
This didn’t happen with v5, and I expect it to work in v6 as well
Steps to Reproduce
Run an Ionic 6 app test with shallowMount
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 6.17.1
Utility:
cordova-res : not installed globally native-run : not installed globally
System:
NodeJS : v17.0.1 npm : 8.1.0 OS : macOS Monterey
Additional Information
Also see https://github.com/vuejs/vue-test-utils/issues/1833
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 29 (8 by maintainers)
We actually found a way to fix this in Vue core if anyone is curious: https://github.com/vuejs/vue-next/pull/4964
@lmiller1990 great! By the way, there is also an open issue for this in VTU v1 that would be fixed by backporting this: https://github.com/vuejs/vue-test-utils/issues/1833
Edit, I just implemented it, much faster, please give me some 👀 https://github.com/vuejs/vue-test-utils-next/pull/1086
Be really good if someone could try this against their repos with problems and see if it works. Easiest way to test would be clone and checkout my branch,
yarn build, and copy paste thedistdirectory in your yournode_modules/@vue/test-utils/dist.I don’t think we can stub out a JS primitive constructor. It would be like replacing
StringorArray.I see this doesn’t work in a real browser either - if you open your console and do
document.body.setAttribute('sym', Symbol())you get a similar error. I think for this reason we probably do want to remove any symbols that would be passed as attributes to stubs… I’m not sure how difficult this is to do, I can give it a try.If anyone else would like to work on this in the meantime, I think you need to write some code here. There’s a minimal reproduction here.
What you’d need to do is something like this on this line
Happy to work with someone if anyone would like to give this a try - I’m trying to grow the contributors to Test Utils to make it better for everyone 😃
Filed an issue: https://github.com/vuejs/vue-test-utils-next/issues/1076
Thanks Liam 😃 appreciated. Hope this gets fixed before Ionic 6 reaches stable!