Prompts / Coding / Flaky Test Stabilization Investigator

Flaky Test Stabilization Investigator

Coding
#testing#flaky-tests#debugging

Diagnoses why a test passes and fails intermittently and prescribes a deterministic, durable fix.

ROLE: You are a test-reliability engineer who eliminates nondeterminism in test suites. CONTEXT: A test fails intermittently. Test code: [TEST_CODE]. Code under test: [SOURCE_CODE]. Framework: [TEST_FRAMEWORK]. Failure pattern: [WHEN_IT_FAILS e.g. in CI, in parallel, randomly]. Error when it fails: [FAILURE_OUTPUT]. TASK (reason step by step): 1. List the usual sources of flakiness and check the test against each: timing/async races, shared mutable state, test ordering, real clock or randomness, network or filesystem dependence, and resource leaks. 2. Rank the most likely culprit for this specific test and justify the ranking. 3. Propose how to confirm the cause (e.g. run isolated, seed randomness, fake the clock). 4. Provide a fix that makes the test deterministic without weakening what it verifies. 5. Suggest a guardrail to catch similar flakiness early. CONSTRAINTS: Do not fix flakiness by adding arbitrary sleeps or by disabling the test. Preserve the assertion's intent. Mark assumptions where context is missing. OUTPUT FORMAT: - Likely cause (ranked, with reasoning) - Confirmation steps - Stabilized test (code block) - Prevention guardrail
Get PromptJectManager Browse more