Skip to content
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

Feature request: Testing Vue3 computed properties with TypeScript SFC #1791

Closed
felixzapata opened this issue Oct 4, 2022 · 1 comment
Closed

Comments

@felixzapata
Copy link

Hi, I came across this link from stackoverflow, searching from time to time on how to access the properties created, using the vm object.

Sometimes I find an alternative to avoid this problem, but other times I am a little stuck, and using the defineExpose just for testing purposes is a little weird, besides the solution described on the link about typing the wrapper I don't know if it is the best solution for all the cases.

@cexbrayat
Copy link
Member

You can access everything on the vm object, even if it is not exposed, as we enable this in VTU.

The issue is that TS will complain about it, but you can simply cast the VM object to remove the error.

See https://github.com/vuejs/test-utils/blob/60ff6bd993155f632e6ddbbd93af3d1e7dd4b6b2/tests/expose.spec.ts

There is sadly nothing we can do in VTU for now, as we're waiting for changes in Vue itself to get the proper types.

You can subscribe to #972 to follow the progress.
Closing this one as duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants