NestJS · Testing · Senior · Debugging
Scenario: flaky e2e due to module singletons holding state.
Short Interview Answer
Reset modules between tests, avoid shared mutable singletons, or use request-scoped carefully.
Detailed Explanation
Close app after suite. Isolate DB. Watch open handles (Jest).