Skip to content

feat: toBeVisible custom matcher #13

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

Merged
merged 2 commits into from
May 18, 2018
Merged

feat: toBeVisible custom matcher #13

merged 2 commits into from
May 18, 2018

Conversation

gnapse
Copy link
Member

@gnapse gnapse commented May 18, 2018

What:

A new .toBeVisible custom matcher, as discussed in #7

Closes #7

Why:

Because checking for this manually is not trivial.

How:

Using getComputedStyle on an element to check if it's not visible either via display: none or visibility: hidden|collapse. Also checks parent nodes all the way to the top, if any of them is not visible, the element is not visible as well.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

@gnapse gnapse added the enhancement New feature or request label May 18, 2018
@gnapse gnapse self-assigned this May 18, 2018
@gnapse gnapse requested a review from kentcdodds May 18, 2018 02:55
@codecov-io
Copy link

codecov-io commented May 18, 2018

Codecov Report

Merging #13 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #13   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           7      8    +1     
  Lines          67     76    +9     
  Branches       15     17    +2     
=====================================
+ Hits           67     76    +9
Impacted Files Coverage Δ
src/to-be-visible.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c50a1b...62fa3ae. Read the comment docs.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome. I'm fine with whatever you decide about opacity 👍

README.md Outdated
* it does not have its css property `display` set to `none`
* it does not have its css property `visibility` set to either `hidden` or
`collapse`
* its parent element is also visible (and so on up to the top of the DOM tree)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about opacity: 0? That's a pretty common way to make things invisible as well. Hmmm...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmmm, yes. Good point 🤔

@gnapse gnapse merged commit e832958 into master May 18, 2018
@gnapse gnapse deleted the pr/to-be-visible branch May 18, 2018 13:37
@gnapse
Copy link
Member Author

gnapse commented May 18, 2018

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gnapse
Copy link
Member Author

gnapse commented May 18, 2018

I think the feature I like the most about semantic-release is that it leaves this message above in PRs once they get released after being merged. So many times I find an issue in a library that I'm having trouble with, I find that it has been merged, but there's no way to know if it's just on master, or beta or rc release, or the latest stable release. It's frustrating.

@kentcdodds
Copy link
Member

Yeah! I love that feature too!

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

Successfully merging this pull request may close these issues.

3 participants