-
Notifications
You must be signed in to change notification settings - Fork 33
How to render components with accessors: true? #196
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
Comments
I think that all that needs to be done is to add 'accessors' to the list of recognized options. See my associated PR #197 |
@yanick @Visual-Dawg This is no longer working, at least for me. I'm getting the following error:
|
@yuliankarapetkov Can you provide an example where it's sprouting that error? |
@yanick I am running unit tests (same result with Jest and Vitest). I want to test the props of a component. It works as expected if I add the following to the component:
But adding |
As in, the unit tests of svelte-testing-library itself, or unit tests of your own project. Because here I have the dreaded "works for me":
|
@yanick sorry for not being clear - unit tests in my own project. |
Can you provide a link to a repo that has this unit test, or a simplified version of it that exhibit the problem? |
@yanick yes, here's a Stackblitz demo |
YES! Thank you. You need to also add a
block in |
@yanick thanks a lot! Is it possible to set this option conditionally only when used for unit testing and for production builds? |
Would'nt this also affect the non-test build though? |
@yanick - Can you comment on the question from @eunukasiko (above)? That is, would adding the following to If so, would it be possible to put that setting in one of the test config files (e.g.: |
Sorry, lost track of this issue. :-) And yup, setting it directly like put above in
|
How can I render a component with
accessors
set totrue
?According to this release, it looks like it should exist.
But when I do this:
I get this:
Also when I try to access the prop directly like this:
I get this:
- Error: <VolumeControl>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'
I also found this from here, which does work:
But I have no idea why this works and it is undocumented. It is also quite cumbersome to write.
The text was updated successfully, but these errors were encountered: