GuideAutohealing

Autohealing Failing Tests

When a scenario fails, AutoReg first decides who is wrong — the test, the application, the spec, or the environment — and only then proposes a fix. Tests that are genuinely broken (a selector moved, a label changed) are healed against the live app. Failures where the application violates the spec are never healed away; they become defects for your coding agent (see Fixing Defects).

The triage step

After a failed run, run_tests diagnoses the failure with:

  • the exact failed step and error from execution.log;
  • the spec’s own scenario block for this test — the reference for what the app should do;
  • run history — when it last passed, and whether the test body was the same;
  • captured diagnostics — console errors, page errors, failed requests and 5xx responses recorded during the run (diagnostics.json in the run folder);
  • source drift — whether the feature’s source files changed since autoreg.md was generated;
  • a live accessibility snapshot of the page, taken right then.

The result is a classification:

ClassificationMeaningWhat Reggie offers
test-defectthe element exists under a different selector/label, or the test asserts something the spec never stateda page-grounded fix to the test, applied only after you approve
app-defectthe spec states the expectation and the live app violates itfile a defect for your coding agent — never a test edit
spec-driftyour source changed after the spec was generatedre-run generate-autoreg (delta mode), then run again — or file a defect anyway; it records the drift for the developer
environmentthe app was unreachablecheck the app is running; rerun
flakya timeout-shaped failure passed on one automatic retrynothing to fix

Every classification comes with a confidence (high, medium, low) and the reasons behind it. The diagnosis is saved as diagnosis.json in the run folder.

Healing a test defect

Run test(s)
    ↓ failure classified as test-defect
Reggie presents the issue and the proposed fix, grounded in the live page
    ↓ you approve
apply_scenario_fix
    Writes the corrected scenario-NNN.json
    Re-runs the scenario to confirm

Triggering it from chat

"Fix the failing tests"
"Heal scenario-004"
"Why is scenario-007 failing?"

For pure questions (“why did it fail?”, “when did it last pass?”) Reggie uses analyze_test_runs only — no browser, no changes.

Targeted healing

"Heal scenario-003 — the login button selector changed"
"The email field on /signup now has aria-label 'Work email', update scenario-002"

Reggie confirms the change with you and applies it through regenerate_failed_test.

Reviewing a fix before applying

Every test change goes through a confirmation:

Agent: "I found that [aria-label='Email address'] is now [aria-label='Work email'].
       Updated scenario-002 step 2. Apply this fix?"

You: "yes"   ← applies the fix and re-runs
You: "no, the label is 'Company email'"   ← Reggie uses your correction

Bulk healing after a deployment

After a large UI change, run the full suite and then:

"Heal all failing tests"

Reggie walks the failures one by one, showing each classification. Test defects are healed with your approval; app defects are offered as defects to file; a stale spec is pointed out once.

When autoheal cannot fix a test

SituationWhat to do
The app is wrong, not the testFile the defect — Fixing Defects
Your app changed and the spec is staleRe-run generate-autoreg; it updates only what changed, then “apply the spec delta”
Feature was removed from the appRe-run generate-autoreg; the delta deprecates its scenarios
Multi-step flow redesignedRe-run generate-autoreg; the delta hands the restructured scenarios back for regeneration
Flaky test (timing issue)Add a wait step or increase a timeout: "Add a 2s wait before step 4 in scenario-008"

Regenerating a scenario from scratch

"Regenerate scenario-006 from scratch using the current app"

This uses generate_scenario_from_page, which re-navigates the live page and generates a fresh test — discarding the old steps entirely.

Tips

  • Run the suite after every deploy — then “heal failing tests”; real bugs surface as defects, not as silently weakened tests.
  • Keep autoreg.md up to date — re-run generate-autoreg after changing your app; delta mode makes it cheap.
  • Check medium and low confidence — Reggie flags uncertain calls; read the reasons before approving.
  • Videos help diagnosis — enable video recording in settings so you can see exactly what happened before the failure.