Giter Site home page Giter Site logo

snap.swift's People

Contributors

dcordero avatar jeehut avatar skyweb07 avatar vojtechvrbka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

snap.swift's Issues

Autolayout issues

When using libraries like SnapKit or Cartography the layout constraints won't update, we need to manually call view.layoutIfNeeded() in order to force layout updates

Crash with Custom Fonts

Hey there!

I've been trying to use this framework and stumbled across this issue.
It appears that Custom Fonts don't load on Unit Tests.

Do you know any workaround this? Or will you think on supporting it somehow?

Thanks ๐Ÿ‘๐Ÿป

Weird framework naming [in docs]

I find it pretty weird to import something with an underscore in Swift. I'm switching over from FBSnapshotTestcase to Snap.swift mainly because this library is written in Swift (not Objective-C) โ€“ but this line makes me really feel like it's not designed for Swift at all:

import Snap_swift

Couldn't we rename the library to what it should be named, just Snap? Even the project file is Snap and seeing Snap.swift as a file whose name is Snap also implies the library should be called Snap.

I would even find SnapDotSwift or SnapSwift better then Snap_swift.

Remove `test` method prefix from reference files

Currently, when I follow the XCTest naming guidelines and write test names like this:

    func testBasicRendering() {
        expect(snapshotView).toMatchSnapshot()
    }

I get files named like this:

I would have expected the name to be reference_basicrendering, so the test prefix should be removed as it is part of any test method. It's redundant information.

Image metadata differs depending if images are recorded under iOS 9 or iOS 10

UIImage+Render currently uses the old UIGraphicsBeginImageContextWithOptions API before iOS 10, and on iOS 10 it starts to use the new UIGraphicsImageRenderer.

Because of this, when you generate test images under iOS 9, the image metadata will differ from the metadata of test images under iOS 10.

My workaround is to only generate the image using the old API...

SpriteKit support

Snap will render an empty, transparent image for SKViews. As a workaround, checking and handling for Spritekit in UIView+Render seems to do the trick:

if let skview = self as? SKView {
    return UIImage(cgImage: skview.texture(from: skview.scene!)!.cgImage())
}

UITraitCollection support

When writing layout code, you should rely on the view/viewController's traitCollection instead of just the frame of the view.

However, when executing the snapshot tests for a device, the traitCollection during the test execution is the same as the current simulator, which is not ideal when using expect(view).toMatchSnapshot(for: .allDevices) since an invalid collection is passed here.

We should either notify this in the documentation or (preferably) override the traitCollection of the UIView using override trait collection

Integrate kaleidoscope

Hi, thanks so much for this library!

I recently migrate from FBSnapshotTestCase and I was wondering if it would be possible to integrate Kaleidoscope?
It was very useful in FBSnapshotTestCase when it fail to compare easily with Kaleidoscope with the
ksdiff command line directly in the console.

Thanks !

Multiple device screenshots

Make the lib to be able to take screenshot from view controller with multiple sizes

something like example

expect(viewController).toMatchSnapshot(for devices: [.iphone4, .iphone5s])
expect(viewController).toMatchSnapshot(for: .allDevices)

Landscape support

It would be nice if there would be support for setting the view to landscape orientation.
Maybe just treating them as a separate Device? Like:

extension Device {
  public var size: CGSize {
    switch self {
    // ...
    case .iPadAir: return CGSize(width: 768, height: 1024)
    case .iPadAir_Landscape: return CGSize(width: 1024, height: 768)
    // ...
  }
}

Debugging failure on Travis CI

I have a consistent failure for GitHawkApp/StyledTextKit#44 only on Travis CI that I'm struggling to debug. Everything is green locally, but just a single test repeatedly fails on Travis.

If I run the same xcodebuild command locally, everything passes. Same goes for testing within Xcode.

Any tips?

Default simulator?

I'm new to snapshot testing, are there are recommending/guidelines to follow when testing?

I have this strange behaviour when I create images for iPhone x it passes and when I try to use another simulator it fails. from the diffs, I can see that the UI is slightly higher by about 4/5 px.

Device.iPadAir.size.width = 788?

Is there a reason for setting the width to 788 or is this a typo?
Also, does it need a special device for the iPad mini which has the same resolution as the iPad Air?

Wrong Carthage dependencies

Hi there and thanks for this library. I just wanted to try this out using Carthage but I noticed immediately that when adding this library via Carthage it installs two dependencies. I couldn't find those dependencies defined in the podspec though and the only usage I find in the project is here during testing.

Currently you are specifying those dependencies as framework dependencies. What you really want if you only need them for testing is to specify them as development dependencies. You can do this by using a file named Cartfile.private instead of Cartfile. Actually don't need a Cartfile to support Carthage if you don't have any dependencies you're relying on. It's enough to have a shared schema to support Carthage.

Project file paths with spaces don't work

This line returns nil when the project path has a space in it. I tried hacking around this, but am getting blocked at the moment. I'm going to update my project paths for the time being, but wanted to flag that this took me a minute to debug.

Make size property of Device type public

In one of my tests I need to see what a view would look like on different devices, but the view is going to be part of a scrollview and therefore is potentially longer than the screen is long. I'd like to test that my view looks correct for each width of a device, but there's no way currently to do that.

The easiest way to allow this is to make the Device sizes public.

Support camelCase for test method names

Currently, when I follow the Swift guidelines and write test names like this:

    func testBasicRendering() {
        expect(snapshotView).toMatchSnapshot()
    }

I get files named like this:

I would have expected the name to be reference_testBasicRendering or at least reference_test_basic_rendering, but Snap doesn't seem to recognize camelCased method names which are the Swift default convention. This should be definitely added IMHO.

API to expect UIImage

It would be awesome if there would be an API to compare an UIImage to be able to visually inspect images, for example to test rendering code without creating full views.

Something like: expect(image: UIImage)

Current workaround: expect(UIImageView(image: image))

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.