Snapshot management & diffing

Emerge automatically generates and diffs snapshots on your behalf, eliminating complicated CI setup with Emulators, file storage, and golden/diffing management.

Generation & Hosting

Emerge generates snapshots on Pixel 7 emulators with default display and accessibility settings. Generation usually takes ~5 minutes or less but is largely dependent on the number of tests. Emerge handles test coordination and sharding on your behalf.

Based off of Git information sent with the upload, Emerge stores snapshots corresponding to each upload. Snapshots for a specific upload are visible from the "Snapshots" tab.

Snapshots corresponding to a build are visible in the Snapshots tab in the Emerge UI.

Snapshots corresponding to a build are visible in the Snapshots tab in the Emerge UI.

Naming & image keys

Emerge uses the name set in the take() block as the "key" for storage and diffing.

class ExampleMainActivityTest {
  
  @get:Rule
  val snapshots = EmergeSnapshots()

  @Test
  fun basicActivityView() {
    ..
    
    // The primary key for saving/diffing this snapshot is the "Main Activity" string.
    snapshots.take("Main Activity", activity)
  }
}

For generated composable snapshots, the name is the composable function's name.

/**
 * If Composable snapshot generation is enabled, Emerge will generate a snapshot test
 * for this composable with the name "TextRowWithIconPreview".
 */
@Preview
@Composable
fun TextRowWithIconPreview() {
  TextRowWithIcon(
    titleText = "Title",
    subtitleText = "Subtitle"
  )
}

Diffing

Emerge diffs snapshots based on Git information uploaded with each build. Emerge will diff snapshots based on the key logic mentioned above. If a matching key is not found for base or head, Emerge will consider this image "Added" or "Removed" respectively.

Snapshot diffs are visible in the Emerge UI under the "Snapshot diffs" tab. Emerge generates a diff image for each snapshot, showing in red the pixels that have changed between builds.

Snapshot diffs are shown in the Snapshot DIffs tab. The old (base), new (head), and diff images are shown if a snapshot has changed, with any changed portion shown in red in the diff image.

Snapshot diffs are shown in the Snapshot DIffs tab. The old (base), new (head), and diff images are shown if a snapshot has changed, with any changed portion shown in red in the diff image.

Clicking on the image card opens a slider view which can be used to visualize the change between the base & head snapshot images.

Clicking an image diff card opens the slider view, which can be used to easily visualize the change between old (base) and new (head) snapshots.

Clicking an image diff card opens the slider view, which can be used to easily visualize the change between old (base) and new (head) snapshots.