Testing WebComponents
# news
c
📣 New post: Testing Lit components created with TypeScript and Vite using Web Test Runner https://www.enkelmedia.se/blogg/2024/4/23/testing-lit-components-created-with-typescript-and-vite-using-web-test-runner
w
Interesting post @Markus Johansson be curious to know what your tests look like. Is there common things/patterns to test for
m
Thanks @Warren Buckley! Still exploring ways to test. In the core they are testing things like “is the component an instance of X”, one can also test public properties etc. all the examples I’ve found so far is very explicit. Like querying the shadowDOM for a button to click etc. I’m looking for a cleaner way to approach it but not found anything yet.
In this scenario the component that I'm testing have a nested component (think I'm testing a "Button Group" that contains "Button"), seems like the way it's implemented in UUI is to query the shadowRoot to get a reference to these elements. It would be much nicer if it was possible to use the syntax used by Playwright, to basically "get element by text", "get element by label" etc. to avoid having to hardcode the inner details of the component into the tests. Seems like early days and probably need to do more research as well
7 Views