On this page
Debugging, DevTools & Testing
Prev: Progressive Enhancement & Accessibility | Up: tutorials | Next: index
Rel: ES Modules & Error Handling, Reflow, Repaint & Performance, Python Testing and Debugging
Ref: MDN Web Docs — Firefox & Browser DevTools
Tags: #public #web #platform #tutorials #debugging #testing
Contents
- > Browser DevTools Workflow
- > Console Diagnostics & Breakpoints
- > Zero-Dependency Assertions & Timing
Browser DevTools Workflow
- Elements / Inspector: Inspect live DOM, Computed styles (exact cascade winner & box model), Flex/Grid overlays, and the Accessibility Tree.
- Sources / Debugger: Set line breakpoints, conditional breakpoints, DOM-mutation breakpoints ("Break on subtree modifications"), and
fetch/XHR breakpoints. - Network: Inspect request/response headers, status codes, CORS preflights, waterfalls, and throttle bandwidth/CPU.
- Performance & Memory: Record flamegraphs to spot long tasks (>50 ms), forced synchronous layouts, and detached DOM node leaks via heap snapshots.
Console Diagnostics & Breakpoints
console.table([
{ route: "/items", status: 200, ms: 14 },
{ route: "/health", status: 200, ms: 2 },
]);
// Pause execution when DevTools is open (equivalent to Python's breakpoint())
// debugger;
Zero-Dependency Assertions & Timing
Use console.assert() and performance.now() directly in the browser, or Node's built-in node:test and node:assert/strict for CLI test suites:
function clamp(value, min, max) {
return Math.max(min, Math.min(value, max));
}
const t0 = performance.now();
console.assert(clamp(15, 0, 10) === 10, "upper clamp failed");
console.assert(clamp(-3, 0, 10) === 0, "lower clamp failed");
console.log(`Assertions finished in ${(performance.now() - t0).toFixed(3)} ms`);
Linked from
Related notes
- tuts/web/tutorials Linked here; links to this page; shared tags: #platform, #tutorials, #web
- tuts/web/tutorials/progressive_enhancement_and_accessibility Linked here; links to this page; shared tags: #platform, #tutorials, #web
- tuts/python3/tutorials/intermediate_python_and_software_engineering/testing_and_debugging Linked here; shared tags: #debugging, #testing, #tutorials
- tuts/javascript/tutorials/modules_and_error_handling Linked here; shared tags: #tutorials, #web
- tuts/web/rendering/reflow_repaint_and_performance Linked here; shared tags: #platform, #web
- tuts/programming/software_design/testing_and_maintainability links to this page; shared tags: #testing
- tuts/index Linked here
- tuts/programming/software_design links to this page
- tuts/web/tutorials/forms_validation_and_fetch shared tags: #platform, #tutorials, #web
- tuts/web/tutorials/vanilla_interactive_components shared tags: #platform, #tutorials, #web