Node.js · Senior · Question 56 of 75
Why does test isolation matter in node --test, and how does it work by default?
- 1All tests share one process to save memory
- ✓Correct answer: Each test file runs in its own process by default, so global state and mocks don't leak between files
- 3Tests run in the browser
Explanation
--test-isolation=none runs files in one process, which is faster but can leak state. Inside one file, tests share state and you must reset it yourself.