Giter Site home page Giter Site logo

Comments (7)

lewie9021 avatar lewie9021 commented on August 18, 2024

This sounds like a pretty good idea. I've been using the debug method quite often, and it's usually just to check that at element exists or not. I've found that styling can useful in some cases though, particularly when the component tree has several views for layout. They kind of provide some context.

I agree that they should definitely stay in snapshots as they play a very useful role in sanity checking the rendered output.

from native-testing-library.

bcarroll22 avatar bcarroll22 commented on August 18, 2024

Thanks for the feedback @lewie9021! I think this is a good call out.

My team really only ever sees debug when the library calls it because something wasn't found, and then what we're usually looking for at that point is what is actually on the screen instead of what we thought was there. But, good point that not everyone uses it that way. At some point, depending on the feedback we get, I may just publish a beta with styles stripped out and see what folks think about it.

Just wondering, have you checked out jest-native? Especially for asserting/checking styles, it's super useful!

from native-testing-library.

lewie9021 avatar lewie9021 commented on August 18, 2024

I think it's great that debug is ran automatically if there is a failure and I use it for exactly that. The cases when I use it manually is usually during the creating of tests, especially when I'm dealing with complex forms. I think publishing a beta would make the most sense.

I've not just yet, but it's certainly something I'll be looking into very soon. Out of curiosity, does the disabled matcher take into account accessabilityStates too? I think it could be useful to have a selected matcher too. This is something I've had to write myself recently.

from native-testing-library.

bcarroll22 avatar bcarroll22 commented on August 18, 2024

Yep, it does take the accessibility state into account! Another thing to keep in mind if you’re looking for something that’s selected is that you can do this:

getByText(
  /hello/i,
  { selector: ({ props }) => props.accessibilityStates.includes(‘selected’) }
);

I can take a look at a pull request for a selected matcher ☺️ I’m not sure without looking at it if we’d include it, because selected is an accessibilityState which could be covered in jest-native by:

expect(element).toHaveProp(‘accessibilityState’, [‘selected’])

but I could still take a look if you don’t think these options cover your case! 💯

from native-testing-library.

lewie9021 avatar lewie9021 commented on August 18, 2024

Thanks for the tip on the second parameter. I didn't realise that was possible!

I think my current knowledge of the two repos is too limited to be comfortable with submitting such a PR at this time. To avoid derailing this discussion any further, I'll potentially raise an issue in the future to debate it more directly. I appreciate the alternative approaches you have suggested :)

Please keep us posted on the beta release. I'm interested in testing the proposed debug output.

from native-testing-library.

bcarroll22 avatar bcarroll22 commented on August 18, 2024

I’ve thought about this more and researched how it works with inline styles in dom-testing-library, and decided this would be too much custom behavior. This is going down a path of implementing custom behaviors that I’d really rather this library not deal with or maintain for now.

That said, it may be very possible for someone to build a plug-in for NTL that could print the native test instances this way, maybe it would be a good ecosystem package 🤷‍♂️

from native-testing-library.

ajsmth avatar ajsmth commented on August 18, 2024

After reading this, I doubt you'll be interested but I've submitted a PR for this exact issue #70 . I'm not familiar with how a plugin would work in this instance, I would be interested in moving it to a plugin if you're not interested in adding it to this repo -- would you be willing to point me in the right direction for this?

from native-testing-library.

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.