Coder Social home page Coder Social logo

Comments (16)

orta avatar orta commented on July 23, 2024

I'm seeing this on UIView based tests. The issue can lie in four places.

  • FBSnapshots (unlikely)
  • Quick (unlikely)
  • Our Nimble Extension (highest chance imo)
  • Swift ( sigh )

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

Yeah could be. We also don't have the same robust supporting framework that we do in eigen to ensure that view controllers are presented with a frame, for example.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

OK, seeing some more consistent behaviour. If you have a test that's failing (for me it's usually ConfirmYourBidArtsyLoginViewControllerTests), you can force the view to load:

expect(sut.view) != nil

That alone won't help the test pass. Instead, pause the tests in the debugger just before the sut is tested. Quick look its view (it's empty). Close the quick look window and quick look it again (it's no longer empty). And the test will pass from now on.

Not sure what to make of these findings but will continue looking.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

Interestingly, using an asynchronous matcher solves the problem:

expect(sut).toEventually(haveValidSnapshot(named:"default"), timeout: 1.0, pollInterval: 0.05)

The timeouts are interesting. Anything less than 0.3 and they fail frequently. Anything over that and it never fails. So I'm thinking there's some part of this that thinks it's being animated maybe? Not sure.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

@orta Good hunch to test the FBSnapshotTest case individually. I used this code on a failing test:

let result = FBSnapshotTest.compareSnapshot(sut, snapshot: "ConfirmYourBidEnterYourEmailViewControllerTests_swift_default", testCase: sut, record: false, referenceDirectory: "//Users/ash/Dropbox (Personal)/bin/eidolon/KioskTests/ReferenceImages")
expect(result) == true

And it never failed. So the problem is almost certainly in the Nimble-Snapshots matchers (note that the method I'm calling above belongs to FBSnapshotTest, a class in Nimble-Snapshots).

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

Actually I may have spoken too soon...

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

Yeah so this is happening without using anything from Nimble-Snapshots.

var snapshotController: FBSnapshotTestController = FBSnapshotTestController(testClass: sut.dynamicType)
            snapshotController.recordMode = false
            snapshotController.referenceImagesDirectory = "//Users/ash/Dropbox (Personal)/bin/eidolon/KioskTests/ReferenceImages"
            let result = snapshotController.compareSnapshotOfView(sut.snapshotObject, selector: Selector("ConfirmYourBidEnterYourEmailViewControllerTests_swift_default"), identifier: nil, error: nil)
expect(result) == true // failed

So my gut says that it's either in iOS 8 or storyboards. Going to try and reproduce in a fresh project.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

Unless it's snapshotObject ...

@objc protocol Snapshotable {
    var snapshotObject: UIView? { get }
}

extension UIViewController : Snapshotable {
    var snapshotObject: UIView? {
        self.beginAppearanceTransition(true, animated: false)
        self.endAppearanceTransition()
        return self.view
    }
}

Maybe Swift doesn't like side-effects in computed properties in protocols?

from eidolon.

orta avatar orta commented on July 23, 2024

https://i.imgur.com/P2fhcL7.gif

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

Ha.

Yeah sorry for all the chitchat here. Kind of rubber-ducking I guess.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

Nope, this is something with Facebook's lib and iOS 8 / Swift.

let sut = ConfirmYourBidEnterYourEmailViewController.instantiateFromStoryboard()

sut.beginAppearanceTransition(true, animated: false)
sut.endAppearanceTransition()

var snapshotController: FBSnapshotTestController = FBSnapshotTestController(testClass: sut.dynamicType)
snapshotController.recordMode = false
snapshotController.referenceImagesDirectory = "//Users/ash/Dropbox (Personal)/bin/eidolon/KioskTests/ReferenceImages"
let result = snapshotController.compareSnapshotOfView(sut.view, selector: Selector("ConfirmYourBidEnterYourEmailViewControllerTests_swift_default"), identifier: nil, error: nil)

expect(result) == true // fails

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

OK, so I can't reproduce the error with Storyboards and FBSnapshotTestController. So I think it might be Quick.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

I can't get it to reproduce with a plain XCTestCase, so I think it's something with Quick. Going to look at it again in the morning.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

This is a problem with either iOS 8, Xcode 6.x, or Storyboards, as the issue occurs with vanilla Xcode projects. I've opened a Stack Overflow question with more details.

from eidolon.

segiddins avatar segiddins commented on July 23, 2024

@ashfurrow given that 0.3 seconds is the default CoreAnimation implicit animation timing, my guess is that there's a so sort of animation going on.

from eidolon.

ashfurrow avatar ashfurrow commented on July 23, 2024

@segiddins Nah, this is a problem with the iOS API. This issue was actually closed by #80@orta, feel free to reopen if you're still experiencing intermittent failures.

from eidolon.

Related Issues (20)

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.