July 21, 2026
Endtest vs Playwright for Testing Theme Switching, Persisted Preferences, and Dark Mode Regression Risk
A practical comparison of Endtest and Playwright for theme switching, persisted UI state, and dark mode regression testing, with tradeoffs for QA, frontend, and platform teams.
Theme switching sounds simple until it becomes a regression surface. A user toggles dark mode, refreshes the page, signs out and back in, opens a different browser, or lands on a settings page with a persisted preference from last week. Suddenly the test is no longer checking a single button. It is checking storage, authentication state, rendering consistency, and whether the app respects the user’s preference workflows across sessions.
That is where the choice between Endtest and Playwright becomes more than a tooling preference. It becomes a decision about who owns the suite, how much code the team wants to maintain, and how much stateful browser behavior needs to be covered without turning every test into a mini software project.
This article focuses on one narrow but common problem set, testing UI state that survives refreshes, logins, and preference changes. The goal is not to crown a universal winner. It is to help QA managers, SDETs, frontend teams, and engineering leaders choose a setup that fits their workflow, especially when dark mode regression testing is part of the release risk.
Why theme switching is a harder test case than it first appears
Theme switching is often implemented as a simple toggle in the UI, but the behavior usually depends on several moving parts:
- a local preference stored in
localStorage, cookies, or server-side profile data - hydration or client-side bootstrapping logic that reads the preference on startup
- CSS classes, media queries, or CSS custom properties that change the rendered output
- cross-tab or cross-device persistence rules
- authenticated and anonymous user flows that may use different storage paths
A common failure mode is not the toggle itself, but the transition around it. For example:
- the theme is applied on the first page load, then lost after refresh
- a preference is saved locally but not synced to the user profile
- login merges a guest theme with an account-level preference in the wrong order
- some routes render in the old theme because the app shell and lazy-loaded pages disagree
- dark mode styles work in the main app but fail in modals, date pickers, or third-party widgets
That makes persisted UI state a better mental model than theme toggling alone. If your test only clicks the switch and checks one selector, it may miss the bugs users actually feel.
The core question is not, “does the toggle work?” It is, “does the preference survive the lifecycle that real users put it through?”
What Playwright gives you for state persistence testing
Playwright is a strong fit when a team wants full control over browser setup, assertions, fixtures, and state management. It is especially attractive for frontend and SDET teams that already work in TypeScript or JavaScript.
For theme switching, Playwright usually shines in three areas.
1. Direct control over browser storage and sessions
Playwright gives you access to browser contexts, storage state, cookies, and local storage patterns. That makes it straightforward to model user preference workflows precisely.
A minimal example might look like this:
import { test, expect } from '@playwright/test';
test('theme preference persists after refresh', async ({ page }) => {
await page.goto('/settings');
await page.getByRole('switch', { name: /dark mode/i }).click();
await expect(page.locator('html')).toHaveClass(/dark/);
await page.reload(); await expect(page.locator(‘html’)).toHaveClass(/dark/); });
That is easy to read, and for many teams it is enough. But the test is only as good as the selectors, setup, and cleanup around it.
2. Flexible setup for authenticated flows
Persisted preference bugs often show up only after login, because guest and authenticated states use different storage paths. Playwright can authenticate once, save the session, and reuse it across tests.
import { test, expect } from '@playwright/test';
test('theme follows the signed-in user profile', async ({ page }) => {
await page.goto('/login');
await page.getByLabel('Email').fill(process.env.TEST_USER_EMAIL!);
await page.getByLabel('Password').fill(process.env.TEST_USER_PASSWORD!);
await page.getByRole('button', { name: 'Sign in' }).click();
await page.goto(‘/preferences’); await page.getByRole(‘switch’, { name: /dark mode/i }).click(); await page.goto(‘/dashboard’);
await expect(page.locator(‘body’)).toHaveClass(/dark/); });
This is powerful, but it also exposes the maintenance cost. The more state a test owns, the more setup code it needs, and the more likely it is to become brittle when login or preference flows change.
3. Fine-grained assertions for visual and semantic checks
Theme regressions are not only about dark classes. They are about text contrast, icons, focus rings, overlays, and components that inherit theme tokens incorrectly. Playwright supports screenshots, role-based queries, and accessibility-oriented assertions, which helps teams write higher-value checks.
The tradeoff is that those checks are still code. That is good for power and bad for shared ownership if the rest of the QA team does not live in the same codebase.
Where Endtest changes the maintenance equation
For teams that want broad coverage of preference-driven UI regression without building and maintaining a framework stack, Endtest is worth serious consideration. It is a managed, agentic AI Test automation platform, and its self-healing behavior is particularly relevant when the app under test evolves around theme-related selectors, labels, and DOM structure.
Endtest’s self-healing tests are designed to recover when locators stop matching because the UI changed, by evaluating surrounding context and substituting a more stable locator automatically. The practical value here is not that it hides problems, but that it reduces the number of false failures caused by incidental UI churn. That matters when preference screens are reworked frequently, and the actual risk you care about is state persistence, not CSS refactors.
A few properties make Endtest a strong fit for this specific test category:
- tests are authorable as editable, human-readable platform steps
- non-developers can participate without learning a programming language
- the platform manages the execution environment, so teams do not have to own the full runner and browser infrastructure
- healed locators are logged, which keeps the behavior reviewable instead of opaque
- self-healing applies to recorded tests, AI-generated tests, and tests imported from Selenium, Playwright, or Cypress
That last point is useful in practice. Many teams already have scattered coverage for UI preferences in code. If the actual pain is maintenance, not creation, a platform that can absorb existing tests and reduce locator churn is more attractive than starting another framework branch.
The real comparison is not syntax, it is ownership
People often compare Playwright and Endtest as if the main question were whether to write tests in code or in a recorder. For theme switching, the more relevant question is who owns the following pieces over time:
- authentication setup
- browser environment management
- fixture data for user preferences
- selector updates after UI redesigns
- debug workflow for flaky preference tests
- reporting and triage when a dark mode test fails on one route but not another
With Playwright, the team owns all of that. That is not a flaw, it is the design. For engineering teams with strong test code practices, the upside is control and composability. The downside is that preference coverage can become concentrated in a small number of people who understand the framework deeply.
With Endtest, the platform absorbs more of the operational burden. That can be a better fit when QA managers need broader participation, or when engineering leadership wants to reduce the number of manually maintained browser scripts for stateful UI coverage.
A practical evaluation matrix for theme switching tests
If you are deciding between the two, evaluate the tool against the failure modes you actually see.
Choose Playwright when you need:
- tight integration with application code and CI pipelines
- complex state setup, custom fixtures, or unusual auth flows
- developer-owned tests that sit close to the product codebase
- advanced assertions around DOM behavior, accessibility, or screenshots
- reusable code abstractions for many related state workflows
Playwright also fits better when the team expects to write a lot of test logic around the theme system itself, for example, validating multiple theme variants, user roles, or preference propagation across micro-frontends.
Choose Endtest when you need:
- broader team participation in authoring and maintaining tests
- less infrastructure ownership
- lower sensitivity to locator churn in a UI that changes often
- coverage for preference workflows without building a framework around them
- faster onboarding for QA or cross-functional contributors
Endtest is especially compelling when the main regression risk is not algorithmic complexity, but stale locators and limited maintenance bandwidth. That is often the case for UI preference pages, settings screens, and dashboard shells that change as product design matures.
Dark mode regression testing needs more than one assertion
A good dark mode regression test should inspect more than a single class or switch state. Consider a layered approach:
- verify the preference control changes the app state
- verify the state persists after refresh
- verify the state survives logout/login if that is the intended product behavior
- verify at least one representative content page renders in the chosen theme
- verify a few high-risk components, such as modals, menus, and form controls
That last point is important because dark mode regressions often hide in surfaces that were not designed with theme tokens from the start. Third-party components are also common failure points.
A code-first Playwright test can model this very precisely, but the team must maintain the logic and selectors for every checked surface. A managed platform like Endtest can reduce the cost of keeping that coverage alive, which is often the harder part of the problem.
Example: how a persisted preference workflow breaks in real life
Imagine a SaaS app where the user can switch between light and dark mode. The app stores the preference locally for anonymous users, then writes it to the user profile after login.
A robust test should catch several classes of bugs:
- the toggle updates the UI immediately, but the save request fails silently
- the theme is restored after refresh, but only on the landing page
- login overwrites the preference with a server default
- logout clears a preference that should remain local
- a route transition re-renders in default theme before hydration completes
A Playwright suite can express each step explicitly. That is useful when product logic is unusual and assertions need to be very specific.
An Endtest suite can cover the same user journey with less framework overhead, which is often a better fit when the problem is regression coverage rather than implementation-level verification.
The hidden cost center is not test creation, it is triage
For theme switching, teams usually underestimate how much time goes into debugging failures that are not true product bugs. Common sources include:
- locators changing after a settings page redesign
- tests running against cached sessions that no longer match the expected preference state
- flaky timing around hydration or async preference loading
- environment differences between local, CI, and browser cloud runs
- screenshots failing because of small layout shifts rather than actual theme defects
Playwright handles these problems well when the team has the discipline to manage waits, storage state, and fixtures carefully. But that discipline itself is an ongoing cost.
Endtest’s self-healing behavior helps most when the failure is caused by a locator mismatch rather than a logic issue. That does not eliminate triage, but it does reduce the noise from superficial DOM changes, which is a real productivity gain for preference-heavy UI suites.
If your theme tests fail mainly because a selector changed, not because the theme behavior changed, a self-healing platform can save a meaningful amount of maintenance time.
When Playwright is the better strategic choice
Even if Endtest is a better operational fit for many teams, Playwright remains the stronger choice in some situations.
Use Playwright if:
- your frontend team already owns a large Playwright stack
- you need to write custom test utilities around API setup, login, or feature flags
- the preference behavior depends on browser APIs or app internals that need code-level introspection
- the team wants test logic reviewed like application code
- you are standardizing on one framework for both UI and integration-level browser testing
Playwright is also attractive when the organization values maximum portability of test code and is comfortable paying the maintenance tax that comes with a flexible framework.
When Endtest is the better operational choice
Endtest is a strong fit if the team wants to cover preference-driven UI workflows without multiplying framework ownership. That includes cases where:
- QA needs to author or update coverage without waiting on engineering bandwidth
- the app’s settings and account flows change often, and selector churn is high
- the business wants reliable regression coverage on dark mode and other persisted preferences without deep infrastructure work
- the team values transparent healing and readable steps over code-level extensibility
- the test portfolio includes a mix of recorded journeys, imported framework tests, and AI-assisted creation
For organizations that are already stretched thin on maintenance, this can make Endtest a better practical investment than another code-heavy test path.
A simple decision rule
If the main challenge is expressing complex browser logic, choose Playwright.
If the main challenge is keeping preference workflows covered as the UI evolves, choose Endtest.
That is the cleanest way to think about it.
A realistic implementation pattern for both tools
Many teams do not need an either-or decision for the whole stack. A common pattern is:
- use Playwright for deeper engineering-owned flows, feature-specific behavior, and tests that need custom fixtures
- use Endtest for cross-functional regression coverage, especially on preference screens, theme switching, and user-facing settings journeys
- reserve code-heavy tests for logic that truly needs code
- keep broad UI-state coverage in a platform that reduces maintenance overhead
This split often matches organizational reality better than a single-tool standard. The test suite ends up closer to the work ownership model of the team.
Practical checklist for selecting a tool for dark mode and persisted state
Before deciding, ask these questions:
- Does the preference persist in local storage, cookies, or the backend?
- Does the test need to survive logout/login?
- How often do UI labels and layout change on the settings page?
- Who will update the tests when selectors move?
- Do you need code-level assertions, or is user-visible behavior enough?
- Is browser infrastructure something your team wants to own?
- Are flaky failures from locators, timing, or actual logic bugs?
If the answers point toward high churn and shared ownership, Endtest becomes more attractive. If the answers point toward custom logic and code-centric maintenance, Playwright is the more natural fit.
Conclusion
Theme switching tests are really persisted UI state tests. Once you include refreshes, logins, and preference workflows, the problem becomes less about clicking a toggle and more about preserving the user’s intent across the app lifecycle.
Playwright is excellent when a team wants full control, custom logic, and code-native test engineering. Endtest is compelling when the goal is to maintain broader regression coverage with less infrastructure, less locator babysitting, and more participation from the people who actually review UI behavior. Its agentic AI and self-healing approach are particularly relevant for dark mode regression testing, where the product surface changes often and the important signal is whether the preference still works, not whether a class name survived unchanged.
For teams evaluating Endtest versus Playwright specifically for theme switching testing, the decision usually comes down to ownership. If you want a framework, choose Playwright. If you want a managed platform that reduces maintenance while still keeping tests reviewable and editable, Endtest is the more practical choice.
For a broader view of how this fits into test automation strategy, it can also help to think in terms of total maintenance cost, not just initial setup, which is why managed execution and self-healing matter so much in this category.