-
Notifications
You must be signed in to change notification settings - Fork 3
How to Test Custom Element in Jest #10
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
Hello and my pleasure! To be quite honest, I never got around to testing web components and don't anticipate that I will anytime soon. I did some digging and I definitely see your troubles in finding resources around testing web components with Jest. I'm sorry I can't be of more help, and if you do find a solution, please feel free to post it here for others who might run into the same thing. |
You don't have to test svelte's custom-elements as a special case. Just write test cases like you write for the normal svelte component. Use import name instead of custom tag name in test file (only exception when the component in question has nested child custom-elements). In the Below example, Foo is a web-component with custom name - "component-foo" but i am using the "Foo" name only.
|
Thanks for providing this info @tal1992! |
Hey! Thank you for this very useful repo.
I see that you've mentioned in a TODO on the Readme that you'll add more documentation testing web components. I'm struggling with this myself. I am already using the Testing Library, but it doesn't see to work properly with custom elements.
How do I import a custom element in Jest and use it? I'm not exporting everything as custom elements, and am using this recipe to only expose things that I need as web components instead of having all child components also be custom elements.
Now how do I import this and set it up in Jest? Please give me an idea on how to get started.
Thank you again!
The text was updated successfully, but these errors were encountered: