An Introduction to Paparazzi for Snapshot Testing

<p>Snapshot testing allows you to ensure that your output continues to behave as expected. This is useful because as you revisit your code, some changes might cause something to break.</p> <p>When writing snapshot tests for Jetpack Compose components, you first need to have your code in a working state. Then generate a snapshot of its expected output given certain data. The snapshot tests are committed alongside the component.</p> <p>Paparazzi&nbsp;is an Android library you can use to create those snapshots for your apps in a simple and friendly way and compare them. One of the advantages this library has over its competitor&nbsp;<a href="https://github.com/pedrovgs/Shot" rel="noopener ugc nofollow" target="_blank">Shot</a>&nbsp;is that it doesn&rsquo;t need an emulator to run the tests, it just runs in the unit test stage which is&nbsp;<em>much</em>&nbsp;faster.</p> <h1>Set up</h1> <p>Let&rsquo;s begin the setup process for our first test! To get started, we need to make some changes to the root&nbsp;<code>build.gradle</code>&nbsp;file. First, we&#39;ll add the necessary dependency for Paparazzi and apply the plugin. The latest version available at the time of writing is 1.3.1.</p> <p><a href="https://androidminded.com/an-introduction-to-paparazzi-for-snapshot-testing-b45a0be718bc">Visit Now</a></p>