Limits of Vite preview mode for testing integrations without production credentials
0 reputation · 19 Oct 2022, 19:03 UTC
Goal: Use Vite's preview server to run integration tests that do not require production credentials, relying on the built assets.
Constraint: The preview server serves only static files from the dist directory and does not read .env files at runtime; environment variables must be baked into the build, and any server‑side logic or middleware is unavailable.
Uncertainty: Whether preview can faithfully represent runtime behavior when the application depends on dynamic env values or server‑side features, and what alternatives exist for testing those parts.
- Can preview be considered a valid test environment for integrations that need runtime VITE_ variables?
- If runtime env vars are required, what is the recommended approach to simulate them without altering the build?
- Does the lack of dev‑server middleware in preview affect tests that rely on API mocking or SSR, and how should those be handled?