-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(browser): support toBeInViewport
utility method to assert element is in viewport or not
#8234
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
feat(browser): support toBeInViewport
utility method to assert element is in viewport or not
#8234
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
hmm...some tests related to my work seems to be failing, I will see later 🙇 |
…t is in viewport or not Close: vitest-dev#7650. This is a suggested feature in that ticket. toBeInViewport is implemented in playwright, and this is port to vitest
35e02b4
to
e4a1aaa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just docs missing
Thank you for reviewing! some tests have still been failing on CI...(but in my local environment, these tests pass 🤔 ) Let me more investigating... |
… element is in viewport or not
I understood, I forgot to run I've fixed the tests to pass on browsers other than Firefox. However, before I tackle the docs and Firefox tests, I have a question 🙇 I've implemented The issue is that the callback function passed to the Intersection Observer API executes after the assertion within a synchronous process. Consequently, when To work around this, I've tentatively implemented a Promise-based solution in eb29fd7. This approach, however, inevitably leads to a usage pattern like Is this API design acceptable? I feel it might be fine because ExpectationResult itself encapsulates a Promise, but I haven't found other examples, so I wanted to ask. |
Yes, it is fine to always return a |
3f8a755
to
23f347e
Compare
… element is in viewport or not
23f347e
to
5f2b411
Compare
Thank you for reviewing and your answer! Also, I wrote document about so PR is ready for review! Please review this if you have time! |
Description
Close: #7650
This is a suggested feature in that ticket. toBeInViewport is implemented in playwright, and this is port to vitest
Hi team 👋 I am a one of vitest fun, and I wanted to enhance vitest feature.
As a first step, I implemented
toBeInViewport
feature invitest/browser
package which is suggested in #7650Perhaps, I could overtake some context, so please feel free to point out that if there is something I overtake. Additionaly, regarding issue #7650, some time has passed since its creation. If there has been an internal decision not to proceed with this feature, please don't hesitate to close the issue.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.