🐛
Flaky Test Debugger
Diagnose and fix intermittently failing tests
prompt template
Help me fix this flaky test: **Test code:** ``` [PASTE_TEST_CODE] ``` **Behavior:** [BEHAVIOR — e.g., "passes locally, fails in CI 30% of the time"] **Error when it fails:** [ERROR_MESSAGE] Investigate these common causes of flaky tests: 1. **Timing issues** — race conditions, missing awaits, setTimeout reliance 2. **Test isolation** — shared state between tests, missing cleanup 3. **Non-deterministic data** — random values, Date.now(), UUIDs in assertions 4. **Environment differences** — CI vs local (timezone, locale, resources) 5. **External dependencies** — network calls, database state, file system 6. **Order dependency** — test relies on another test running first For each applicable cause: - Explain why it causes flakiness - Provide the specific fix - Show a before/after code comparison Also suggest how to add a retry-proof test for the same behavior.
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
More Debugging Prompts
Related debugging templates from the vault
🐛
Network Request Waterfall Analyzer
Use this prompt to network request waterfall analyzer with AI assistance
Beginnerdebuggingnetwork
🐛
Stack Trace Decoder and Fixer
Use this prompt to stack trace decoder and fixer with AI assistance
Intermediatedebuggingstack-trace
🐛
Systematic Bug Diagnosis
Get structured help diagnosing a bug you cannot figure out
Beginnerdebuggingtroubleshooting
🐛
Systematic Memory Leak Hunter
Systematically identify and fix memory leaks in a production application using heap snapshots and allocation tracking
Advanceddebuggingmemory-leak
You Might Also Like
Prompts from other categories that share similar tags
🧪
TestingPRO
Mutation Testing Configuration
Set up mutation testing to verify your test suite catches real bugs
Shared:testingci-cd
🚀
DevOpsPRO
GitHub Actions Matrix CI Pipeline
Build a comprehensive GitHub Actions CI pipeline with matrix testing
Shared:ci-cdtesting
🧪
TestingPRO
E2E Test Scenario Writer
Write end-to-end test scenarios for user flows
Shared:testingci-cd
🧪
TestingPRO
Smoke Test Suite for Deployments
Use this prompt to smoke test suite for deployments with AI assistance
Shared:testingci-cd
Keep Exploring the Vault