Debugging Commands
Debug failing tests with Node.js inspector, verbose output, and Jest's built-in debugging tools. Find and fix flaky tests, memory leaks, and timing issues.
10 commands
Pro Tips
Debug with Chrome DevTools: 'node --inspect-brk node_modules/.bin/jest --runInBand' then open chrome://inspect.
Use 'jest --verbose' to see individual test names and status — helps identify which test in a suite is failing.
Find flaky tests with 'jest --detectOpenHandles --forceExit' — shows async operations that aren't cleaned up.
Common Mistakes
Using '--forceExit' masks real issues. It hides tests that don't clean up async operations properly. Fix the root cause.
Timer mocking with 'jest.useFakeTimers()' can cause confusing failures. Always call 'jest.useRealTimers()' in afterEach.