-
Notifications
You must be signed in to change notification settings - Fork 791
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
The color-contrast check doesn't work in JSDOM #595
Comments
@thecristen what do you mean by "false passing result"? Is it returning this in the |
I would just turn off the color contrast rule in JSDOM, because you're right that it won't ever work. We don't recommend testing color contrast in JSDOM due to the lack of support. |
@marcysutton yes, but it should be passing the results for this rule back in the |
Thanks for the comments, this made me look at it a bit carefully. I shouldn't have taken the absence of violations as a "passing" indication (though, I've seen too many tests follow that pattern..). @dylanb you're right in that the results end up in the |
Curious to know what was your next step here? Did you remove this from unit testing as it requires manual intervention? |
@dylanb @marcysutton looks like the range and selection APIs were added to JSDOM in v16 (jsdom/jsdom#2719). Does this mean color contrast checks can work with axe-core in JSDOM? Does it need any updates to axe-core or should it work as is with JSDOM v16 or higher? |
@mohanraj-r I tested out jsdom 18.0.1. Looks like something about the range API is still not fully working as I get this error when running a test:
|
Seeing the same here. Is there any known fix for this? |
Unfortunately without full support of the APIs we use, there's not much we can do for a fix. I just tested with jsom 19 and still am getting the not supported message.
|
Is this still the case? Or does anyone know another alternative library that will check for color contrast? |
@tounsoo I'm a little late to the party but we've been using axe-core with Cypress to test color contrast. Cypress runs tests in a browser vs JSDOM. |
Hi there, thanks for building this fantastic library!
I've never gotten bad color contrast to create violations when testing React components with JSDOM. It seems to always return a false passing result (well, when it's not timing out, but that's a known JSDOM issue). I've created an example based off of this project's jest+react example here.
I'm guessing it doesn't work because JSDOM has not implemented ranges as part of its DOM implementation, and the code that checks for color contrast depends on that (
document.createRange()
). But the false passing result is a bit concerning.The text was updated successfully, but these errors were encountered: