-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Component testing doesn't work with Vue 3.4's defineModel #29522
Comments
What bundler tool are you using? From my experience I can say that you might want to configure your bundler to opt-in this feature. Would be also nice to see your cypress dev server configuration |
I'm using Vite 5 (which is needed to use Vue 3.4). Also using yarn rather than npm.
|
It appears like you your config is inferred from the one you use for your app bundling.
Try to follow the code snippet above. This might come in handy as well: |
That works, thanks! |
(Though should probably be available by default in a future release as it's a stable feature in Vue now) |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has been closed due to inactivity. |
Current behavior
defineModel
is stable as of Vue 3.4 so we recently refactored a lot of our code to take advantage of it. However, this has broken our component testing. Previously, we were able to pass modelValue as a prop when mounting a component in a component test, like so:and the test would mount the component with the stub data we gave it.
Since moving to
defineModel
(specifically for this caseconst rule = defineModel<Object>({ required: true });
), it first gives us the errordefineModel is not defined
. We can get around this by importingdefineModel
from Vue in the component, though we shouldn't have to as likedefineEmits
anddefineProps
,defineModel
is automatically available inside<script setup>
.Adding that import in gets us around the initial error, but then we get an error that
rule is undefined
.The component itself isn't broken and works in both production and Cypress e2e testing. I've tried upgrading to the latest version of Cypress (13.90 at the time of writing) but get the same results.
Desired behavior
There should be a way of mounting a component that makes use of
defineModel
and allows you to pass stub data to it. You should also not have to importdefineModel
.Test code to reproduce
Test:
Partial component script:
Cypress Version
13.9.0
Node version
20.11.1
Operating System
macOs 11.6
Debug Logs
Other
No response
The text was updated successfully, but these errors were encountered: