When asked to write UI tests (playwright), I've seen Claude Code do essentially the following:
const elem = document.querySelector(".foo"); // actual element that exists
elem.innerHTML = '<div class="bar"></div>';
const child = elem.locator(".bar"); // child we actually want to test for
expect(child).toExist()
const elem = document.querySelector(".foo"); // actual element that exists elem.innerHTML = '<div class="bar"></div>'; const child = elem.locator(".bar"); // child we actually want to test for expect(child).toExist()
Gee thanks Claude, what a great test...