Back
Interactive Explainer

Testing and Debugging

Test critical paths; debug with DevTools and minimal repros.

🎯Key Takeaways
Unit, integration, E2E.
DevTools: Sources, Network, Elements.
Minimal repro; check async/state.

Testing and Debugging

Test critical paths; debug with DevTools and minimal repros.

~1 min read
Be the first to complete!
What you'll learn
  • Unit, integration, E2E.
  • DevTools: Sources, Network, Elements.
  • Minimal repro; check async/state.

Why test frontend code

Tests catch regressions and document behavior. Unit tests cover pure logic (utils, hooks); integration tests cover components with their dependencies; E2E tests cover key user flows (login, checkout) in a real browser.

Focus on what matters most: critical paths, fragile logic, and areas you change often. Avoid testing implementation details; test behavior so refactors do not break tests unnecessarily.

Debugging in the browser

console.log and debugger are quick ways to inspect state. DevTools Sources (or Debugger) lets you set breakpoints, step through code, and inspect variables. Network shows every request, status, and timing; Elements shows the DOM and computed styles.

When a bug is hard to reproduce, isolate it: strip the page down to the smallest case that still shows the issue. Check async timing, dependency arrays in effects, and whether state updates are immutable.

Common issues

State not updating? In React, ensure you are not mutating state; use immutable updates. Check dependency arrays in useEffect/useMemo so they include every value the effect uses. CORS or 404? Verify the request URL and that the server sends the right headers.

Layout shift? Reserve space for images and dynamic content (aspect-ratio, min-height, skeleton). [MDN – Testing](https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started).

Key takeaways

  • Unit, integration, E2E.
  • DevTools: Sources, Network, Elements.
  • Minimal repro; check async/state.

Related concepts

Explore topics that connect to this one.

Suggested next

Often learned after this topic.

Browser Dev Tools

Ready to see how this works in the cloud?

Switch to Career Paths for structured paths (e.g. Developer, DevOps) and provider-specific lessons.

View role-based paths

Sign in to track your progress and mark lessons complete.

Discussion

Questions? Discuss in the community or start a thread below.

Join Discord

In-app Q&A

Sign in to start or join a thread.