Giter VIP home page Giter VIP logo

Comments (4)

nalexn avatar nalexn commented on May 30, 2024 1

Hey @matiasvillaverde, there was a proposal for improving the library in a way of making the lookup more dynamic and tolerant to the view structure changes.

Snapshotting or auto-generating the full path in the code saves time while you write the test, but the test remains fragile, where a tiny change in the view hierarchy could break it.

So far I have in plans digging towards that approach, but your proposal makes sense and I'll keep it in mind as a fall-back solution.

from viewinspector.

matiasvillaverde avatar matiasvillaverde commented on May 30, 2024

Cool! It makes sense. In the case of snapshot, a change that breaks the tests can be a trigger to re-run the generation of the tests.

Keep me in the loop, in case I can contribute to it, it is a topic that interest me.

from viewinspector.

nalexn avatar nalexn commented on May 30, 2024

@integer256 with the recent release of the aforementioned dynamic query I can outline what is technically available now.

To begin with, each view in the hierarchy now can be located dynamically with find function, and after that, by calling pathToRoot, you can get a string representing the full inspection chain that leads to this view. For example:

let view = MyCustomView()
let sut = try view.inspect().find(ViewType.Text, where: { try $0.string == "Hello, world!" })
print(sut.pathToRoot)
// "anyView().hStack().group(1).vStack(0).text(0)"

The path can be used in place of find, and this thing resembles the process of "autogeneration" you were talking about. However, the usefulness of the replacement is questionable.

Looking at the functionality of the library you mentioned, I can add the feature of printing the entire view tree. It can, in theory, also print applied attributes and modifiers, however, it cannot yet calculate the layout frames.

Basically, ViewInspector can print a human-readable view structure with all the submitted values, and this dump will change every time something is tweaked inside the view. I cannot understand the use case where this can be helpful though - probably because I never used snapshot-generating libraries in tests. Let me know If such a full "dump" of the view hierarchy's structure is actually what you'd expect.

from viewinspector.

matiasvillaverde avatar matiasvillaverde commented on May 30, 2024

@nalexn That is great news! Thanks for the update.

I can imagine that would be helpful to have a method to print a human-readable view structure, as an intermediate step of writing the final test. Given that, due to the complexity of the hierarchy, sometimes it's difficult to inspect the correct view.

The new find function already simplifies the process of writing test a lot!

from viewinspector.

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.