After Loki.js served us well for some years we finally converted our Visual Regression Testing** logic to use the Storybook Test Runner.
The benefits:
- it's way faster
- it has better official support
- it does more (component smoke tests,
playtests, extensibility for more like a11y tests) - it's way more stable
But the setup might be non-trivial and there are some rough edges. The biggest downside: while it is way faster it could be even more faster, if we could just use generate images against the Storybook Dev Server. Sadly this was very flaky and error boundaries would always fail (I assume this is because of Reacts unfortunate decision to re-throw errors in Dev Mode). See also this issue.
What I do now in order to generate images locally is a custom "production" build (without minification and optimization and just the stories that I actually want to test visually).
The other tricky part was the Playwright setup. In order to get the same results across machines we want to run Playwright in a Docker container. For various reasons I decided to use the Network API of Playwright. That means I'll only run Playwright in the Docker container, but I keep my running Storybook instance on the host. (At least in the local setup. Within the Gitlab CI we run everything inside Docker.)
As a general note: We have a lot of stories in Storybook, but we only want to take images of stories that are inside a components/ directory.
...
..
..