storybook-diff: a GitHub Actions tool that shows visual changes per pull request
The team at PKSHA Technology built an internal tool called storybook-diff. It takes two built Storybook[1] outputs, base and head, and in GitHub Actions it creates a gallery of only the stories whose appearance changed, plus a summary comment for the pull request. The team previously used an external visual regression testing (VRT)[2] service, but its cost grew with the number of PRs and stories, and after moving to the in-house tool the monthly VRT cost fell by about 97% compared with before.
To keep runs fast, the tool narrows the stories it renders in three steps. First, it matches changed files against the dependency graph and renders only the stories that import them, directly or indirectly. Next, it compares each story's HTML and takes screenshots only where the HTML differs; a pixel counts as changed when any RGBA channel differs by more than 24, and a story is marked changed when more than 40 pixels differ. Finally, when page reuse is on, stories with differences are re-captured on a freshly loaded page.
The gallery shows each change side by side or with a slider, can highlight differing pixels, and lets reviewers mark stories as checked with keyboard shortcuts. The PR comment shows counts and collapsed lists per change type, capped at 50 items per type and 60,000 characters. Each story waits for its play function to finish, the DOM to settle, and pending requests to end, with a 3-second limit, instead of the networkidle wait in Playwright[3].
Sources
-
JPZenn JA
Storybook の見た目の差分を GitHub Actions で PR ごとに確認できるようにした






