Giter VIP home page Giter VIP logo

nimble-snapshots's Introduction

Nimble-Snapshots Build Status

Nimble matchers for FBSnapshotTestCase. Highly derivative of Expecta Matchers for FBSnapshotTestCase.

Installing

You need to be using CocoaPods 0.36 Beta 1 or higher. Your podfile should look something like the following.

platform :ios, '8.0'

source 'https://github.com/CocoaPods/Specs.git'

# Whichever pods you need for your app go here.

target 'YOUR_APP_NAME_HERE_Tests', :exclusive => true do
  pod 'Nimble-Snapshots'
end

Then run pod install.

Use

Your tests will look something like the following.

import Quick
import Nimble
import Nimble_Snapshots
import UIKit

class MySpec: QuickSpec {
    override func spec() {
        describe("in some context", { () -> () in
            it("has valid snapshot") {
                let view = ... // some view you want to test
                expect(view).to( haveValidSnapshot() )
            }
        })
    }
}

There are some options for testing the validity of snapshots. Snapshots can be given a name:

expect(view).to( haveValidSnapshot(named: "some custom name") )

We also have a prettier syntax for custom-named snapshots:

expect(view) == snapshot("some custom name")

To record snapshots, just replace haveValidSnapshot() with recordSnapshot() and haveValidSnapshot(named:) with recordSnapshot(named:). We also have a handy emoji operator.

๐Ÿ“ท(view)
๐Ÿ“ท(view, "some custom name")

By default, this pod will put the reference images inside a ReferenceImages directory; we try to put this in a place that makes sense (inside your unit tests directory). If we can't figure it out, or if you want to use your own directory instead, call setNimbleTestFolder() with the name of the directory in your unit test's path that we should use. For example, if the tests are in App/AppTesting/, you can call it with AppTesting.

If you have any questions or run into any trouble, feel free to open an issue on this repo.

nimble-snapshots's People

Contributors

ashfurrow avatar orta avatar esttorhe avatar tibr avatar colinta avatar famanson avatar andreamazz avatar difujia avatar alesker avatar mpurland avatar sammy-sc avatar filwag avatar tomquist avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.