Skip to content

Conversation

@nexxai
Copy link
Contributor

@nexxai nexxai commented Sep 4, 2025

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):

it('ensures the home page meets accessibility requirements in both color schemes', function (): void {
    visit('/')
        ->inLightMode()
        ->assertSee('Hello!')
        ->assertDontSee('Goodbye')
        ->assertEnabled('Press me!')
        ->assertNoAccessibilityIssues(level: 3)
        ->inDarkMode()
        ->assertSee('Hello!')
        ->assertDontSee('Goodbye')
        ->assertEnabled('Press me!')
        ->assertNoAccessibilityIssues(level: 3);
});

❌

Example (and this is necessary for every test):

it('ensures the home page meets accessibility requirements in both color schemes', function (): void {
    visit('/')
        ->inLightMode()
        ->assertSee('Hello!')
        ->assertDontSee('Goodbye')
        ->assertEnabled('Press me!')
        ->assertNoAccessibilityIssues(level: 3);

    visit('/')
        ->inDarkMode()
        ->assertSee('Hello!')
        ->assertDontSee('Goodbye')
        ->assertEnabled('Press me!')
        ->assertNoAccessibilityIssues(level: 3);
});

❌

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:

it('ensures the home page meets accessibility requirements in both color schemes', function (): void {
    visit('/')
        ->inLightAndDarkMode()
        ->assertSee('Hello!')
        ->assertDontSee('Goodbye')
        ->assertEnabled('Press me!')
        ->assertNoAccessibilityIssues(level: 3);
});

@jasonmccreary
Copy link
Collaborator

@nexxai, I like this. But am going to defer to @nunomaduro on the naming and parallelization of this.

@nexxai
Copy link
Contributor Author

nexxai commented Sep 5, 2025

No problem. Thanks for the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants