HeadlinesBriefing favicon HeadlinesBriefing.com

WSL-UI Mock Mode for Safe Development

DEV Community •
×

The developer of WSL-UI built a complete mock mode from the start, not just for automated testing but for development itself. This prevents accidentally deleting real WSL distributions during debugging and allows testing hard-to-reproduce scenarios like network timeouts or corrupted registry entries.

The architecture uses an Anti-Corruption Layer pattern from Domain-Driven Design. Instead of calling `wsl.exe` directly, the app uses traits for external dependencies. This abstraction lets the system swap between real implementations and mock ones that maintain internal state and return controlled responses.

Mock mode activates seven fake distributions with simulated resource usage, registry entries, and disk sizes. It includes an error simulation system to test failure scenarios like timeouts or command failures. The mock is controlled by environment variables and enables faster, safer development without needing actual WSL installations.