Eliminating Flaky Tests: Managing Global Environment State in Vitest
Testing code that interacts with environment variables is a common source of frustration. In the ibime-connect project, we recently encountered flaky behavior in our integration tests—specifically those validating rate-limiting logic—where global state changes weren't being cleaned up correctly, leaking configurations across test suites.
The Problem: State Leakage
When tests mutate `process.