Latest 0.0.4
License MIT
Platforms ios 9.0
Dependencies EarlGrey, FBSnapshotTestCase
Frameworks Foundation, XCTest

CI Status

EarlGrey actions for FBSnapshotTestCase. Provides functional tests counterpart for Nimble Snapshots.


Before using the library you need to have a project integrated with EarlGrey library. It is highly recommended to follow an official installation guide and create a separate test target for feature testing, since they are less reliable than usual unit tests.

Next, make sure to define two environment variables which point to:

  • FB_REFERENCE_IMAGE_DIR – directory containing reference snapshots,
  • IMAGE_DIFF_DIR – directory containing failure snapshots and visual diffs.

Sane default values for those variables are (as proposed in FBSnapshotTestCase README):

Name Value

Now it is time to record your first reference snapshot. Select the reference element using EarlGrey’s selection API and invoke grey_recordSnapshot() action: grey_kindOfClass(AViewToSnapshotClass.self))

Run the test target. The test should fail with the following error:

Image recorded successfully! Replace with grey_verifySnapshot().

Having followed the instruction you should alter the test as following: grey_kindOfClass(AViewToSnapshotClass.self))

That’s it! From now on the tests will verify whether selected view matches reference snapshot.

Device agnostic snapshots

Using grey_recordSnapshot() and grey_verifySnapshot() will not work when executing the tests against devices with differing resoultions and pixel densities. To enable such tests you should use grey_recordDeviceAgnosticSnapshot() and grey_verifyDeviceAgnosticSnapshot() APIs instead. They compare the snapshots paired by the test name and also device type, which means you have to separately record snapshots for all the supported device types.


EarlGreySnapshots glues together two libraries:

Make sure to install them both alongside the project.


EarlGreySnapshots is available through CocoaPods. To install
it, simply add following lines to your Podfile:

pod 'EarlGrey', '~> 1.12'
pod 'FBSnapshotTestCase', '~> 2.1'
pod 'EarlGreySnapshots', '~> 0.0.4'

Don’t forget to run pod install afterwards!

Example project

To run the example project, clone the repo, and run pod install from the Example directory first.


The project derives heavily from ideas found in Nimble Snapshots. Huge credits go to @ashfurrow and other maintainers.


turekj, [email protected]


EarlGreySnapshots is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "EarlGreySnapshots",
    "version": "0.0.4",
    "summary": "EarlGrey action for snapshot testing.",
    "description": "EarlGrey actions for FBSnapshotTestCase. Provides functional tests counterpart for [Nimble Snapshots](",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "turekj": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.0.4"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "source_files": "EarlGreySnapshots/Classes/**/*",
    "frameworks": [
    "dependencies": {
        "EarlGrey": [
            "~> 1.12"
        "FBSnapshotTestCase": [
            "~> 2.1"
    "pushed_with_swift_version": "4.0"

Pin It on Pinterest

Share This