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

feat: Allow mocking getComputedStyle #41

Merged
merged 2 commits into from
Nov 28, 2019
Merged

Conversation

eps1lon
Copy link
Owner

@eps1lon eps1lon commented Nov 28, 2019

window.getComputedStyle is very expensive. To address performance concerns this PR allows mocking this function out.

One could mock a fake implementation that returns always visible elements. The neat part is that is puts users with and without visual impairment on the same level. If your test makes assertions about elements that are visually hidden then even sighted users won't be able to perform it.

Another use case would be wrapping window.getComputedStyle with a caching provider. It's unclear if we should allow providing a factory instead so that cache busting is easier (simply clear it before every call) or if this is responsibility in userland. Either way a factory option can be added later and I want to see usage first.

@eps1lon eps1lon added the enhancement New feature or request label Nov 28, 2019
@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2019

🦋 Changeset is good to go

Latest commit: 3db06db

We got this.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eps1lon eps1lon merged commit eb86842 into master Nov 28, 2019
@eps1lon eps1lon deleted the feat/getComputedStyle-mock branch November 28, 2019 09:36
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.

1 participant