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
Vue stubs not working in cypress 12.3.0 + vue 2.7.14 + script setup #25450
Comments
Thanks for the bug report, I suspect the problem is in the underlying Vue Test Utils library: vuejs/vue-test-utils#2048 We should try fix it there. |
Thanks @lmiller1990! |
Hey @lmiller1990. What is going on?. What is the current status of this bug? It is totally annoying dont being able to test components when <script setup> is used (the current reommended way to declare the setup) 😭. |
To clarify, this only happens in Vue 2 (not Vue 3)? I guess we need to fix vuejs/vue-test-utils#2048. The bug is in the actual Test Utils library. I don't have bandwidth to fix that one right now - I have to maintain the Vue 3 Test Utils, Vue Jest, cypress/vue, and many other libs -- if someone wants to fix vuejs/vue-test-utils#2048 I'd be happy to review and release a patch. In general, I find is less necessary to stub components when I write tests with Cypress anyway - that's one of the things I like about it. Are you attempting to migrate an existing Test Utils suite to Cypress, or writing fresh tests in Cypress? If you'd like to share a specific componen/test you'd like to write, I might be able to make some recommendations. I've found that avoiding stubbing components has helped my tests be more useful and catch regressions. |
Hey @lmiller1990, yes in our case with Vue 3 stubs work as expected. So the problem happens only in Vue 2. |
Current behavior
Cypress fails to stub components when working with Vue 2.7 and using
<script setup>
.I prepared this github project with an example which I'll explain next.
Having a component like:
Where
ChildComponent
can be anything.Cypress fails to stub
ChildComponent
with the following code:Whereas, if I set up the parent component like:
It works like a charm.
Desired behavior
Ideally both components should have the same output. That is, when creating a component with
<script setup>
, Vue stubs should work properly.Test code to reproduce
https://github.com/mverdaguer/cypress-vue-2.7-stubs-not-working
Cypress Version
12.3.0
Node version
v16.19.0
Operating System
macOS 13.1
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: