Testing · Senior · Question 17 of 75
A test passes alone but fails when the whole file runs. What is the likely cause?
- ✓Correct answer: Shared state leaking between tests: module-level variables, unrestored mocks, stores, timers or DOM left behind
- 2The test is too short
- 3The test runner is outdated
Explanation
Run with random order (--sequence.shuffle in Vitest, --randomize in Jest) to surface such dependencies early.