Unit tests and storybook for widgets

Is it possible to create unit tests for widgets? I’ve been looking for some examples in the documentation and in some lightning repositories but I couldn’t find any information about it. Another question I have is related to the creation of stories on storybook for this kind of widgets, The same thing happens that I mentioned before

You’re in luck - check out GitHub - rdkcentral/Lightning-UI-Components: Lightning UI components for both storybook and tests on individual widgets.


Hi, I really appreciate your answer. I know this repository, it is one of my references, but, I haven’t been able to find a test or story for router widgets, so my question is, is it possible to test or create a story for this kind of widgets? Because all the examples I’ve found are for regular components but not for router widgets(e.g. a modal)

Yes, you should be able to do all kinds of widgets. For a router widget you may just want documentation like we did here:


As it’s hard to create an example and you’ll have to build up the whole application from scratch (since most components live inside a page). There are also tests for it which don’t use the lightning-test-render as we need it at the App level:

You should be able to do something similar with testing a Router.

For Modal, that would exist inside a page so you could test that like a normal component.

Also, if you’re using the SDK router (recommended) - you can test that like so: