Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: .toBeVisible error with Pressable function style #134

Conversation

kaibarnes
Copy link
Contributor

@kaibarnes kaibarnes commented Nov 29, 2022

What:

Fixes #133

To fix an error when .toBeVisible is used on a Pressable using a function for the style prop

Why:

Using a function is a documented use case (doc) and so it should be supported.

How:

By adding a check if the style prop is a function and calling it with { pressed: false } as a default value.

Checklist:

  • Documentation added to the docs (N/A)
  • Typescript definitions updated (N/A)
  • Tests
  • Ready to be merged

src/to-be-visible.ts Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #134 (ec0d034) into main (5883ed7) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #134   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        12    +1     
  Lines          208       224   +16     
  Branches        66        70    +4     
=========================================
+ Hits           208       224   +16     
Flag Coverage Δ
node-14 100.00% <100.00%> (ø)
node-16 100.00% <100.00%> (ø)
node-18 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/component-tree.ts 100.00% <100.00%> (ø)
src/to-be-visible.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mdjastrzebski
Copy link
Collaborator

@kaibarnes I've modified the implementation to match RNTL approach, i.e. performing tree walking only using host elements. This should fix the problem.

@kaibarnes
Copy link
Contributor Author

@mdjastrzebski Thanks. I confirmed locally that it seems to be working as expected now

@mdjastrzebski mdjastrzebski merged commit d65e9f2 into testing-library:main Dec 7, 2022
@github-actions
Copy link

github-actions bot commented Dec 7, 2022

🎉 This PR is included in version 5.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toBeVisible failing when used on Pressable with style function
2 participants