-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Issue#2010 Switch to white or black background #2747
Conversation
mochajs#2010 body class=mocha-light or mocha-dark added based on cookie mocha-scheme setting if found. A little button added to bottom of test page which will allow the user to change the setting easily.
The AppVeyor failure on node 0.12.18 doesn't happen for me locally. http 1 passing (19ms) |
(Does anybody know a way to get AppVeyor to actually show the test failure result details? I am only seeing that the test failed, but not what the error/failure was.) I'm not sure why we would need something like this built in when it's straightforward just to add custom CSS to the HTML (which is part of the project using Mocha rather than part of Mocha) or even to re-use that custom CSS by including it by a
|
ScottFreeCode, thanks for your comments. Most of it can be done with CSS except the top right progress circle because it uses a canvas you cannot change the fillStyle with CSS. I based the opacity to match the other |> symbols but can certainly make it more visible. |
mochajs#2010 Removed user interface for the moment. body class=mocha-light or mocha-dark added based on cookie mocha-scheme setting if found. You can activate by adding mocha-dark class to body of your html test runner. Then once you run the tests the cookie is set for a year and you can remove the body class and your preference is retained. This way different team members can have their light/dark setting retained without affecting others.
ok, I've removed the UI toggler for now and just use the color scheme setting from the cookie. To test it I just added class="mocha-dark" to the body tag of my HTML runner and ran the page. I'm not sure where the documentation lies for this: |
mochajs#2010 Make the test replay button more visible in dark color scheme.
mochajs#2010 Moved color scheme code to html reporter which makes more sense.
Hi, thanks for the PR. I'm not sure why the JavaScript is necessary to implement a dark scheme. Simply using your own custom styles should work; there's no requirement to use I'm disinclined to merge this, because it increases complexity and maintenance overhead to benefit a relatively small portion of our userbase (those executing browser-based unit tests in a non-automated fashion) . Mocha can't afford that. I'd encourage you to create a gist or find another way to share your dark color scheme, as I'm sure others may find it useful. Also, there are plugins for browsers such as Dark Reader which you might find useful. Anyway, even if this is not merged, please do not be discouraged from contributing to Mocha. 😄 You may have even created this PR or issue before we added contribution guidelines. Feature PRs are more likely to be merged if they arrive after discussion. There are plenty of other areas in which Mocha needs help, as you can see in the README! |
This is worth revisiting in another PR given widespread support for |
@steve-taylor agree. |
It's been a long time, but I'm updating one of my projects that uses mocha and so am updating this again for mocha 8.3.0. And have a bit of time available. The use of prefers-color-scheme CSS would be a nice (minimal) thing to add but people with vision difficulties may want to turn on light/dark schemes for things independently of changing their entire OS color scheme. For the best accessibility experience the user needs to be able to switch between light and dark as needed. A Javascript change is also needed to properly effect the color scheme change because the circular mocha progress indicator is rendered in a canvas and cannot be seen when you go to dark theme. (see screenshot) So at the very least, even if prefers-color-scheme is used the canvas code must be made aware of that to change the text color. We could get by with a fixed text color of orange or blue for the progress indicator which is pretty visible against both white and black. (obviously we wouldn't want to use green or red as those have semantic meaning about passing and failing.) I can create a fresh pull request which switches the scheme based on prefers-color-scheme and a mocha-dark class name if you're willing. Alternatively I'll create a mocha-dark package on NPM and include the css and javascript file there with full functionality. |
#2010
body class=mocha-light or mocha-dark added based on
cookie mocha-scheme setting if found.
A little button added to bottom of test page which will allow the user to change the setting easily.