-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
v3.2.45: regression in Vue Test Utils wrapper.vm
for script setup variables
#7103
Comments
wrapper.vm
wrapper.vm
for script setup variables
wrapper.vm
for script setup variableswrapper.vm
for script setup variables
This is an intended change to solve dev/prod inconsistencies (#6248), so we should try and see that we can keep it. I think test-utils could use |
Thanks @LinusBorg |
You would have to mimick what the component proxy itself does to an extend: i.e. check the setup state for the accessed key first, and if that fails, try the proxy (for all those public APIs) |
I do something similar here: https://github.com/LinusBorg/vue-mixable/blob/main/src/vmContextProxy.ts |
Ha! I was coming to the same proxy idea on my side: combining with your code, I have something that works with v3.2.45 and v3.2.44 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Closing as intended - it's important to keep the prod/dev behavior consistent for normal users, and it only affects dev behavior, so this change is considered a fix. |
Vue version
3.2.45
Link to minimal reproduction
https://stackblitz.com/edit/vitest-dev-vitest-1djhp4?file=components%2FHello.vue,test%2Fbasic.test.ts,package.json&initialPath=__vitest__
Steps to reproduce
Given a component like:
VTU allows to write a test like:
VTU can access count, times and result (even if only result is exposed) because we are internally using
vm.$.proxy
for the VM in script setup componentshttps://github.com/vuejs/test-utils/blob/ff93e5e60ac8482cf4326f9f83fffa8dac08f8b6/src/vueWrapper.ts#L49-L62
Vue v3.2.45 introduced changes that are breaking this use case.
Is there a way that we can keep this feature in VTU? Either by making the recent changes less breaking, or using another workaround in VTU.
What is expected?
The unit test should succeed, as it does with Vue v3.2.44
What is actually happening?
wrapper.vm
no longer has access to script setup variablesSystem Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: