Our group is currently working on migrating our old widgets libraries to Panel+holoview. Is there any recommended ways (or maybe a few good examples) on how to write unit test for widgets based on Panel and holoview? The widgets are mostly in-notebook file browsers with some helper buttons to navigate our data management system and an image viewer to render the reduction results. We would like to integrate the widget testing into our CI pipelines if possible.
Also, I found one thread back in 2020-03 (Testing the user interface of a panel app) that slightly touched on this topic, but there isn’t a lot of development afterwards.
The developers have recently been using Playwright for UI testing, and have been much happier with that than with previous approaches (e.g. Selenium).
In most of the cases you would actually be writing tests in Python only. Which simplifies things a lot. So they are just normal Python unit tests. Nothing special.
Yes we’ve been using Playwright to write UI tests, i.e. tests that actually check that things get displayed in a browser as we expect. We’ve just started to do that, you can check them out here: panel/panel/tests/ui at master · holoviz/panel · GitHub
An approach to write python tests is to separate as much as possible your UI code (e.g. the widgets) from your code that takes care of the your business logic. This is best done using Parameterized classes (Param — Panel v0.13.1) or using the