Why Screenshot Tests?

Screenshot Tests aren't new.

In 2015, when I worked at Facebook, I open-sourced a library for running Screenshot-tests for Android. That library has gotten widely popular outside of Facebook.

Some of you may be against the idea of Screenshot tests, and might argue that instead one should write unit tests instead. And yes, you're right. In the test pyramid, you would predominantly write unit tests.

UI Tests vs Unit tests

But user interfaces are much harder to "unit" test. Going back to the Facebook example, think about how many different configurations of Newsfeed stories there are: images, plain stories, photos, shares, groups. But that's not all. Facebook (as would any other company) has a core set of UI components maintained by a UI team that almost everybody else in the company uses.

So if the UI team, say, changes the look of a button, the rendering of almost everybody's components changes.

This is a problem! Frontend developers probably made assumptions in their UI based on what these core components looked like. It's important that as soon as the core UI engineers made their changes, that all these other developers get notified that their components are changing.

It's not a bug per se (and in fact, at Facebook we found most of our changes were intentional, not bugs), we just need to make everybody aware of the change.

There are libraries run screenshot tests for Android and also iOS. Facebook pioneered the use screenshot (snapshot) testing but Facebook doesn't run tests the way other companies run it.

This gets to why use Screenshotbot.io, and why not simply use these open source libraries?