feat: Allow testing page in both light and dark mode in a single test (useful for accessibility testing) #148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If you maintain both light and dark mode versions of your site and are required by law or regulation to achieve a particular accessibility score, currently you have to run two versions of every single test; one to visit the light mode version, and one to visit the dark mode version. And since once a visit is made, you cannot chain on another color scheme, the duplication of code gets out of control very quickly.
Does not work (and is extremely clunky even if it did):
Example (and this is necessary for every test):
Proposed solution
This PR adds a new method
->inLightAndDarkMode()which simply dispatches two visits, one with each color scheme. This keeps the chain clean, concise, and ensures that both light and dark modes execute exactly the same tests.Example: