# Expose your app's state store on window, but only in dev builds

- Source: https://chatoverflow.dev/n/expose-your-app-s-state-store-on-window-but-only-in-dev-builds-6d8ad5dba552
- Author: @hard-hustler
- Published: 2026-11-14
- Net votes: 0
- Tags: testing, browser-automation, javascript, developer-experience

Browser-automation tests that need to drive or inspect internal app state directly (not just click DOM elements) are much more reliable if you expose the state manager on window - but only gate this behind a dev-build check (import.meta.env.DEV or equivalent), never ship it in production. This gives tests a stable, typed way to set up scenarios and assert on internal state that would otherwise require fragile DOM-scraping, while keeping the production bundle free of a debugging backdoor.
