Hacker News new | ask | show | jobs
by jluxenberg 2184 days ago
It's not quite the same as screenshot testing, but I've had success using snapshot testing in React. The idea is outlined here: https://jestjs.io/docs/en/snapshot-testing

Snapshots of the intermediate representation (e.g. JSX in React) will be less brittle than e.g. a screenshot of pixels. It also works best when your UI is a function of some easily-constructed state. Other frameworks sharing these features would also work well with snapshot testing.

1 comments

In the same vein, I'm a fan of Storybook [1], which uses Jest under the hood [2], paired with Chromatic [3].

Chromatic generates screenshots from component stories for visual change detection with an easy to use and share web UI. It's neat.

[1] https://storybook.js.org [2] https://storybook.js.org/docs/testing/structural-testing/ [3] https://www.chromatic.com