Self-Healing Tests

Automatically repair failing tests when UI changes break cached action sequences, without manual intervention.

Donobu can automatically repair failing tests without manual intervention. When a test breaks because the UI changed — a button was renamed, a form was restructured, a page flow was adjusted — self-healing re-runs the AI to generate a new action sequence and writes it back to the cache.

What self-healing addresses

Self-healing targets structural breakage: cases where the AI's previously cached action sequence no longer works because the page has changed, but the intent of the test is still valid.

It does not address:

  • Genuine application bugs (the test is supposed to fail)
  • Semantic regressions where the correct behaviour itself has changed
  • Tests that time out due to slow infrastructure

How it works

Test runs → Fails → Evidence collected → AI regenerates action sequence → Cache updated → Annotated as "self-healed"
  1. A test fails during its normal run.
  2. Donobu captures a screenshot, the current DOM state, and an AI-generated triage analysis to understand why it failed.
  3. Donobu re-runs the failed test. On this run, the AI executes the original instruction autonomously again against the current page, generating a new cached sequence.
  4. If the new sequence succeeds, the cache is updated and the test is annotated with self-healed in the Playwright report.

Enabling self-healing

Pass --auto-heal to the CLI when running your tests:

npx donobu test --auto-heal

When --auto-heal is active, Donobu automatically re-runs any failing test with the AI enabled to regenerate the cached action sequence.

Evidence collection

When a test fails, Donobu collects and persists:

  • A viewport screenshot at the point of failure
  • The full page DOM state
  • An AI-generated triage analysis that explains what went wrong and suggests what may have changed

This evidence is attached to the test report and visible in Donobu Studio.

The "self-healed" annotation

After a successful self-heal run, the test is annotated in the Playwright report:

"self-healed" annotation: "Automatically healed by Donobu auto-heal rerun."

This annotation is visible in the HTML report and in Donobu Studio. Use it to track which tests were healed over time and identify areas of the UI that change frequently.

Limitations

  • An AI provider must be configured (DONOBU_API_KEY or equivalent) — self-healing calls the AI to regenerate the action sequence.
  • Self-healing updates the cache but does not modify your test source code. The repaired action sequence lives in .cache-lock/ and will be replayed on the next run.
  • If the application's UI has changed so substantially that the original instruction is no longer achievable, self-healing will fail and the test will remain broken.