-
Notifications
You must be signed in to change notification settings - Fork 245
-
Notifications
You must be signed in to change notification settings - Fork 245
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
Bug: Typescript - type VueWrapper do not allow access component data #1746
Comments
Just to be clear: you have a TS error, but if you use If so, this is sadly expected: as your component is closed, nothing is exposed, and TypeScript (or Volar) do not know that VTU "cheats" to make Sadly, we can't do much on the VTU side, and we need a fix upstream in vuejs/core. We are tracking this in issue #972 , so I'm closing the issue as a duplicate. |
Describe the bug
I'm trying to assert if classes are being applied to my component.
To Reproduce
I have a simple button components that apply some classes if o prop
size
has passed.BasicButton.vue
:The test I write to this component
BasicButton.test.ts
:I've comment on the code above where I tried to do to solve.
I tried a solution proposed at the vue2 version of vue-test-utils vuejs/vue-test-utils#255 (comment) but vue3 seems not export
Wrapper
anymore butVueWrapper
instead, that is not replaceable.I also tried to declare wrapper as
any
, but is not ideal. Proposal: vuejs/vue-test-utils#255 (comment)Expected behavior
I want to pass the right typings to the wrapper and have access to my component static data, following best practices.
By now,
wrapper.vm.sizes
can be access, but typescript keep screaming:Property 'sizes' does not exist on type 'ComponentPublicInstance<...
Related information:
@vue/test-utils
version: 2.0.2Vue
version: 3.2.37node
version: 16.15.1npm
version: 8.11.0typescript
version: 4.7.4eslint
version: 8.23.0@vue/eslint-config-typescript
version: 11.0.0Additional context
The text was updated successfully, but these errors were encountered: