Interview practice question
Tests interfere with each other through a singleton
Backend Engineering · OOP and Design Patterns · Beginner
Tests pass individually but fail when run together, because they share state through a global singleton cache. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Global mutable state leaks between tests.
- Replace singleton access with injected dependency.
- Fresh instance per test.
- Or reset hook (short-term).
- Avoid global state in design.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.