Self-healing: when healing is right and when it harms
Healing a failed test is right when the interface changed but the behaviour did not: then the locator is updated. If the application broke, that is a defect, not a reason to patch the test. Bad healing keeps a test green at the cost of quality: a weakened assertion, a changed expectation, a longer timeout or a skip. Healer patches go into a PR with a diff and need an explanation.
After a redesign 30 tests failed. The healer made everything green in a few minutes. It is too early to celebrate: you need to know what exactly it changed.
Two kinds of failure:
- the test lags behind the interface — a button was renamed, an element moved, but behaviour is the same; the right healing is to update the locator;
- the application broke — the cart total differs, an action is not performed; the right reaction is a defect, not a test patch.
Bad "healing" keeps a test green at the cost of quality: a weakened assertion (toHaveCount(5) → not.toHaveCount(0)), a changed expected value, an increased timeout, skip. According to the Playwright documentation the healer may skip a test if it believes the functionality is broken; that is a signal for a person, not a reason to hide a line in the report.
Commercial tools often store several attributes of an element and, when the main locator is not found, pick the closest match. The heuristic may choose a similar but wrong element ("Delete" instead of "Cancel"), and the test turns green on the wrong action.
Rule. Healer patches go in a PR with a diff. Changed expectations, new skip and timeout changes need a separate explanation. A locator is normal, an expectation is suspicious.
Common mistakes: auto-commit to main; treating a green run as evidence; not checking that the test still fails on broken behaviour.
Short interview answer: "A locator may be healed when the interface changed and the behaviour did not; a changed expectation or a skip is a reason to look for a defect".