--- name: fix-tests description: Runs the failing tests in a scope, diagnoses each failure, and fixes the root cause without weakening assertions, adding retries, or masking app defects. Use when tests fail consistently and you want them repaired. For intermittent failures, use the stabilize-flaky-tests command; to only diagnose without editing, use the explain-test-failure command. argument-hint: "[testScope]" disable-model-invocation: true --- # Fix failing tests ## Inputs Take these from what the user typed after the command, or from the conversation. Ask for any you need that are missing. - `testScope`: test file, folder, or suite to fix (default: the full suite) # Task If the `diagnosing-test-failures` skill is installed, load it before starting. Your goal is to fix failing tests in . If no scope is provided, run the full suite. Do the following: 1. Identify failing tests: - Run the test suite (limited to the given scope) to identify which tests are failing. - Analyze error messages, logs, and traces to understand the root cause of each failure. - Classify each failure before fixing: application defect, test bug, environment/config issue, or flaky test. Rerun a failing test in isolation when you suspect flakiness - an intermittent failure needs a root-cause fix (waiting strategy, test isolation, data setup), not a retry. 2. Fix failing tests: - Modify the test or the code under test to address the root cause. - Ensure that fixes are aligned with the overall test strategy and quality standards. 3. Validate fixes: - Rerun the affected tests to confirm they pass. - For fixed flaky tests, confirm stability by repeating the run when the framework supports it (e.g. Playwright `--repeat-each=5`), not by a single green run. - Rerun the full scope to confirm no new failures were introduced. If tests still fail after 3 fix iterations, stop and summarize what you found, what you tried, and what remains failing. # Guardrails - Never make a test pass by weakening or deleting assertions, increasing global timeouts to mask races, adding retries to hide flakiness, or skipping the test. - Fix waits by replacing sleeps and hardcoded timeouts with condition-based waiting (web-first assertions, waiting for a specific response or state), not by tuning sleep durations. - If the failure indicates a defect in the application code and fixing it is outside the requested scope, stop and report the defect with evidence instead of changing the test to accept the broken behavior. - Keep each fix minimal and explain the root cause in your summary.