Unit: test one small piece alone (a price calculator). Fast, many of them.
Integration: test pieces working together (API + database).
End-to-end: a robot uses the real app in a browser like a user. Slow, few of them, but most realistic.
Say it like this in the interview
“Unit tests verify isolated logic quickly; integration tests verify components together, like an endpoint with a real test database; E2E tests drive the full system through the UI with Playwright or Cypress. I follow a pyramid or trophy shape: many fast tests, a few critical-path E2E tests.”
Test-Driven Development: write a failing test first (red), write the minimum code to pass (green), then clean up (refactor). Repeat.
Say it like this in the interview
“Red, green, refactor. I use it especially for business logic and bug fixes: first a test that reproduces the bug, then the fix, which guarantees it never returns. For exploratory UI work I usually write tests after. With AI-generated code, tests are how I verify it actually does what I asked.”
Coverage shows which lines ran during tests, not whether the tests checked anything meaningful. You can hit 100% with tests that assert nothing.
Say it like this in the interview
“Coverage is a useful signal for finding untested areas, not a quality target. I focus on covering critical paths and edge cases with meaningful assertions; mutation testing measures test quality better.”
It follows a real user’s journey (sign up, buy, pay), is stable, and doesn’t break every time someone changes a CSS class.
Say it like this in the interview
“Cover critical journeys only, select elements by role or test IDs rather than CSS structure, wait for conditions instead of sleeping, isolate test data, and run in CI against a production-like environment. Playwright is my default.”
You can’t test everything, so test what matters most: the features with the highest risk and the code that changed.
Say it like this in the interview
“Risk-based prioritisation: automated smoke and regression suites on critical paths in CI, manual exploratory testing focused on changed areas, and clear communication of what wasn’t tested so the team can decide.”
Test the normal case, the edge cases and the error cases. Each test has three parts: Arrange (set up), Act (call it), Assert (check the result).
import { describe, it, expect } from 'vitest';
import { calculateDiscount } from './discount';
describe('calculateDiscount', () => {
it('applies 10% for SAVE10', () => {
expect(calculateDiscount(200, 'SAVE10')).toBe(20);
});
it('returns 0 for an unknown code', () => {
expect(calculateDiscount(200, 'NOPE')).toBe(0);
});
it('never discounts more than the total', () => {
expect(calculateDiscount(5, 'FLAT10')).toBe(5);
});
it('rejects negative totals', () => {
expect(() => calculateDiscount(-1, 'SAVE10')).toThrow();
});
});
Say it like this in the interview
“Arrange-Act-Assert, with one behaviour per test and descriptive names. I cover the happy path, boundaries like zero, the maximum and negatives, and invalid input. Tests describe behaviour, not implementation, so refactoring doesn’t break them.”
A mock is a stunt double for something slow or unpredictable (payment API, email, clock) so tests are fast and reliable. But if you mock everything, you’re only testing that your mocks work.
Say it like this in the interview
“Mocks, stubs and fakes replace dependencies at boundaries: external APIs, time, randomness. Over-mocking couples tests to implementation and misses integration bugs, so I mock at the edges and prefer real objects or an in-memory or containerised database for integration tests.”
Think about the normal path, wrong inputs, edge cases and security.
Say it like this in the interview
“Valid login; wrong password; unknown email with the same generic message; empty fields; email format validation; password visibility toggle; lockout after N failures; remember-me; session expiry; SQL injection and XSS strings handled safely; keyboard and screen reader accessibility; works on mobile.”
The test depends on something that isn’t always the same: timing, order, dates, shared data, or the network.
Say it like this in the interview
“Timing (fixed sleeps instead of waiting for conditions), test order dependence and shared state, real dates and time zones, randomness without seeds, real network calls, and resource limits in CI. I reproduce by running it repeatedly or in random order, then remove the non-determinism, not just add retries.”