Testing Strategies

1 min read
Rapid overview

Testing Strategies for Frontend and Node.js

Use these notes to explain how you structure tests across UI and API layers.


Test pyramid

  • Unit tests: Pure logic, components, and utilities.
  • Integration tests: Components + data layer, API + DB (mocked network).
  • End-to-end: Critical user flows in real browsers.

Frontend testing

  • Use React Testing Library / Angular TestBed for component tests.
  • Focus on behavior and user intent rather than implementation details.
  • Add accessibility assertions (role, name, focus).
render(<button onClick={onSave}>Save</button>);
await userEvent.click(screen.getByText('Save'));
expect(onSave).toHaveBeenCalled();

API and Node.js testing

  • Use integration tests for request/response behavior.
  • Mock third-party services for deterministic tests.
  • Use schema validation for contract checks.

Performance and visual regression

  • Measure Web Vitals in CI for regression detection.
  • Use visual snapshot tools (Chromatic, Percy, Playwright).

Interview prompts

  • Explain the trade-offs between unit vs integration tests.
  • Describe how you avoid flaky tests.
  • Share how you test responsive layouts.