All Projects → ashfurrow → Nimble Snapshots

ashfurrow / Nimble Snapshots

Licence: mit
Nimble matchers for FBSnapshotTestCase.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Nimble Snapshots

Client Generator
Generate React or Vue.js-based Progressive Web Apps from an Hydra-enabled API. Also support React Native.
Stars: ✭ 286 (-1.72%)
Mutual labels:  hacktoberfest
Patchwork Api
An attempt to reimplement the Minecraft Forge API on Fabric
Stars: ✭ 289 (-0.69%)
Mutual labels:  hacktoberfest
Securedrop
GitHub repository for the SecureDrop whistleblower platform. Do not submit tips here!
Stars: ✭ 3,149 (+982.13%)
Mutual labels:  hacktoberfest
Yii2 Docker
Official Docker images suitable for Yii 2.0
Stars: ✭ 286 (-1.72%)
Mutual labels:  hacktoberfest
Fynedesk
A full desktop environment for Linux/Unix using Fyne
Stars: ✭ 286 (-1.72%)
Mutual labels:  hacktoberfest
React Ace
React Ace Component
Stars: ✭ 3,342 (+1048.45%)
Mutual labels:  hacktoberfest
Phpmailer
The classic email sending library for PHP
Stars: ✭ 17,485 (+5908.59%)
Mutual labels:  hacktoberfest
Examples
Example Revel Applications
Stars: ✭ 290 (-0.34%)
Mutual labels:  hacktoberfest
Regommend
Recommendation engine for Go
Stars: ✭ 288 (-1.03%)
Mutual labels:  hacktoberfest
Vue Cli Plugin Electron Builder
Easily Build Your Vue.js App For Desktop With Electron
Stars: ✭ 3,549 (+1119.59%)
Mutual labels:  hacktoberfest
Socks5
A full-fledged high-performance socks5 proxy server written in C#. Plugin support included.
Stars: ✭ 286 (-1.72%)
Mutual labels:  hacktoberfest
Carbon Charts
📊 📈⠀Robust dataviz framework implemented using D3 & typescript
Stars: ✭ 287 (-1.37%)
Mutual labels:  hacktoberfest
Workflow Core
Lightweight workflow engine for .NET Standard
Stars: ✭ 3,605 (+1138.83%)
Mutual labels:  hacktoberfest
Kube No Trouble
Easily check your cluster for use of deprecated APIs
Stars: ✭ 280 (-3.78%)
Mutual labels:  hacktoberfest
Summer2021 Internships
Collection of Summer 2022 tech internships!
Stars: ✭ 7,275 (+2400%)
Mutual labels:  hacktoberfest
Nestjs Pino
Platform agnostic logger for NestJS based on Pino with REQUEST CONTEXT IN EVERY LOG
Stars: ✭ 283 (-2.75%)
Mutual labels:  hacktoberfest
Eo Locale
🌏Internationalize js apps 👔Elegant lightweight library based on Internationalization API
Stars: ✭ 290 (-0.34%)
Mutual labels:  hacktoberfest
Developerexcuses
A Mac OS X Screensaver which shows quotes from http://developerexcuses.com, inofficial
Stars: ✭ 290 (-0.34%)
Mutual labels:  hacktoberfest
Diff2html Cli
Pretty diff to html javascript cli (diff2html-cli)
Stars: ✭ 287 (-1.37%)
Mutual labels:  hacktoberfest
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+1065.64%)
Mutual labels:  hacktoberfest

CircleCI

Nimble matchers for iOSSnapshotTestCase. Originally derived from Expecta Matchers for FBSnapshotTestCase.

Installing

CocoaPods

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

platform :ios, '10.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'
  pod 'Quick' # if you want to use it with Quick
end

Then run:

$ pod install

Carthage

You need to be using Carthage 0.18 or higher. Your Cartfile (or Cartfile.private) should look something like the following.

github "Quick/Quick" ~> 2.0
github "Quick/Nimble" ~> 8.0
github "uber/ios-snapshot-test-case" "6.0.0"
github "ashfurrow/Nimble-Snapshots"

Then run:

$ carthage bootstrap --platform iOS --toolchain com.apple.dt.toolchain.Swift_3_0

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") {
            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.

Dynamic Type

Testing Dynamic Type manually is boring and no one seems to remember doing it when implementing a view/screen, so you can have snapshot tests according to content size categories.

In order to use Dynamic Type testing, make sure to provide a valid Host Application in your testing target.

Then you can use the haveValidDynamicTypeSnapshot and recordDynamicTypeSnapshot matchers:

// expect(view).to(recordDynamicTypeSnapshot()
expect(view).to(haveValidDynamicTypeSnapshot())

// You can also just test some sizes:
expect(view).to(haveValidDynamicTypeSnapshot(sizes: [UIContentSizeCategoryExtraLarge]))

// If you prefer the == syntax, we got you covered too:
expect(view) == dynamicTypeSnapshot()
expect(view) == dynamicTypeSnapshot(sizes: [UIContentSizeCategoryExtraLarge])

Note that this will post an UIContentSizeCategoryDidChangeNotification, so your views/view controllers need to observe that and update themselves.

For more info on usage, check out the dynamic type tests.

Dynamic Size

Testing the same view with many sizes is easy but error prone. It easy to fix one test on change and forget the others. For this we create a easy way to tests all sizes at same time.

You can use the new haveValidDynamicSizeSnapshot and recordDynamicSizeSnapshot matchers to test multiple sizes at once:

let sizes = ["SmallSize": CGSize(width: 44, height: 44),
"MediumSize": CGSize(width: 88, height: 88),
"LargeSize": CGSize(width: 132, height: 132)]

// expect(view).to(recordDynamicSizeSnapshot(sizes: sizes))
expect(view).to(haveValidDynamicSizeSnapshot(sizes: sizes))

// You can also just test some sizes:
expect(view).to(haveValidDynamicSizeSnapshot(sizes: sizes))

// If you prefer the == syntax, we got you covered too:
expect(view) == snapshot(sizes: sizes)
expect(view) == snapshot(sizes: sizes)

By default, the size will be set on the view using the frame property. To change this behavior you can use the ResizeMode enum:

public enum ResizeMode {
  case frame
  case constrains
  case block(resizeBlock: (UIView, CGSize) -> Void)
  case custom(viewResizer: ViewResizer)
}

To use the enum you can expect(view) == dynamicSizeSnapshot(sizes: sizes, resizeMode: newResizeMode). For custom behavior you can use ResizeMode.block. The block will be call on every resize. Or you can implement the ViewResizer protocol and resize yourself. The custom behavior can be used to record the views too.

For more info on usage, check the dynamic sizes tests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].