---
updatedAt: 2025-07-02T21:10:43.000Z
agentTools:
  projectIndex: https://docs.emergetools.com/llms.txt
---

# Excluding snapshots

Occasionally you might have a snapshot that you only want to use locally and not be tracked by Emerge. We provide multiple options to exclude snapshots from our test results.

# iOS

## Config file

We support packaging an `emerge_config.yaml` file inside the top-level directory of your xcarchive uploaded to our site. In this configuration file, you can specify to exclude based on an exact match or regex match. This solution is the most flexible if you want to exclude an entire range of snapshots, say from a third-party dependency you are linking against.

The schema for this YAML file is as follows:

```yaml
version: 2.0
snapshots:
  ios:
    runSettings:
      - osVersion: 17.2
        excludedPreviews:
          - type: exact
            value: TestModule.TestPreviewProviderType1
          - type: exact
            value: TestModule.TestPreviewProviderType2
          # For preview macros there is a special syntax
          - type: exact
            value: SomePreviewMacroFileId:SomeDisplayName
          - type: exact
            value: AnotherPreviewMacroFileId
          - type: regex
            value: ^TestModule.*$
        envVariables:
          var1: 1
          var2: 2
          var3: 3
        # Use arguments for pseudolanguages like double length strings
        arguments:
          - -NSDoubleLocalizedStrings
          - "YES"
```

## In code

If you want to exclude directly within your Preview code, you can copy the following extension:

```Text Swift
extension View {
  @ViewBuilder func emergeDisabled() -> some View {
      if ProcessInfo.processInfo.environment["EMERGE_IS_RUNNING_FOR_SNAPSHOTS"] == "1" {
        EmptyView()
      } else {
        self
      }
  }
}
```

Note that your the preview's `body` property will still need to be evaluated without any errors for this to work. If the preview crashes when running it will need to be excluded with the yaml file instead.

# Android

Emerge provides the ability to ignore specific snapshots through the `@EmergeSnapshotConfig` annotation's `ignore` parameter. Since these annotations need to live in the source set of the preview (by default the `main` source set), Emerge ships this annotation as part of a separate, `snapshots-runtime` library. You'll need to include this as an `implementation` dependency in whatever soruce set you're intending to ignore snapshots.

As an example, to ignore a Preview in the main source set:

```kotlin MyComposable.kt
// /src/main/com/myapp/MyComposable.kt

@EmergeSnapshotConfig(
  ignore = true,
)
@Preview
@Composable
fun MyComposablePreview() {
  MyComposable(
    text = "Hello, World!"
  )
}
```

And add `snapshots-runtime` dependency as a `debugImplementation` dependency, as Previews are only included in `debug` builds:

```kotlin build.gradle.kts (app module)
dependencies {
  // ...

  debugImplementation("com.emergetools.snapshots:snapshots-runtime:<latest_version>")
}
```

Latest Snapshots Annotations [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.emergetools.snapshots/snapshots-runtime/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.emergetools.snapshots/snapshots-runtime)

<br />

# Ignoring Specific Snapshot Diffs

Sometimes you might have a preview that is particularly flaky and occasionally renders in (for example) two different ways. If it's easy or possible to fix and you don't want this flaky case to show up in future snapshot comparisons, you can ignore a specific diff on the snapshots page:

![](https://files.readme.io/87f00fc2eb97aecb4722280d08f96c1032cd9f9d4d7e0add15276059f271c2ff-image.png)

When you do this, we save the image data of both the before and after images of this snapshot. For all future snapshot comparisons, if there is a specific preview comparison for your org where the two images match the saved case, we will not mark it as a CHANGE.

If you ever want to undo this ignore, you will be able to do so here:

![](https://files.readme.io/2ec5f583ae4e910835d05d9035a79a7548a2ff7111f243bb5ab18dff08fadc34-image.png)