5 interview questions with model answers — practise the English for strong Vitest developer responses.
0 / 5 completed
1 / 5
The interviewer asks: "Why use Vitest instead of Jest for a Vite project?" Which answer is strongest?
Option C shows depth: shared pipeline, zero extra config, alias support, and the honest trade-off of Vite coupling. Interviewers want to hear you understand WHY, not just that you prefer it.
2 / 5
The interviewer asks: "When would you use vi.mock() vs vi.spyOn()?"
Option C is the clearest explanation of the distinction: whole-module vs single-method, plus the decision heuristic (side effects = mock, observe = spy). This shows practical judgment, not just syntax knowledge.
3 / 5
The interviewer asks: "How do you handle tests that depend on the current time or random values?"
Option C demonstrates the right principle — eliminating non-determinism — and shows knowledge of the specific Vitest APIs (useFakeTimers, setSystemTime, spyOn Math.random). The phrase "tests that pass most of the time" is a red flag interviewers look for candidates to name and reject.
4 / 5
The interviewer asks: "What is snapshot testing and when is it appropriate?"
Option C gives the correct definition, the right use case (stable output, regression detection), AND the honest anti-pattern (blind updates). The anti-pattern mention shows maturity — candidates who describe only the positive use cases are missing real-world experience.
5 / 5
The interviewer asks: "How do you measure and improve test coverage meaningfully?"
Option C demonstrates nuanced judgment: branch over statement coverage, critical-path prioritisation, the 80%+ heuristic for business logic, and the anti-pattern of inflating numbers. This is exactly what a senior engineer sounds like.