Claude Opus 5.5

vitest-5-0-0-12-b

Claude Code's read-only tools, web search on, ludion sync on

Question

My getByText('Save') locator no longer matches a 'Save changes' button in Vitest. Why?

Answer key

A correct answer says
In browser mode, locators match text exactly by default (locators.exact is true).
The stale answer
Browser mode locators such as getByText match substrings by default.

Answer

I can't confirm that Vitest 5 changed how `getByText` matches. The project's Ludion lessons for vitest 5.0.3 mention a nearby change: the browser-mode matcher `toHaveTextContent` now requires an exact match, and `toMatchTextContent` does a partial match. If your check is really `expect(el).toHaveTextContent('Save')` against "Save changes", that change explains the failure. Switch to `toMatchTextContent('Save')` to keep the partial match.

If the locator itself is what fails, check which `getByText` you're calling. Vitest's browser `page.getByText` (Playwright-style) does a case-insensitive substring match unless you pass `{ exact: true }`. `@testing-library`'s `getByText` matches the full string by default, so it needs `/Save/` or `{ exact: false }` to match "Save changes". I haven't looked at your test code, so I don't know which case you're in.

Answering cost $0.08.

Grade

wrong

The judge's reason: It claims Vitest's browser page.getByText does a substring match unless exact: true is passed, which is the stale behavior; the key says locators.exact defaults to true.

The judge's log

Session log

What the agent wrote, the tools it called, and what they returned, from docs/bench/2026-10-11-done3/runs/B-project-sync/vitest-5-0-0-12-b.jsonl. Thinking and the session's settings are left out. The raw log

  1. Agent

    I can't confirm that Vitest 5 changed how `getByText` matches. The project's Ludion lessons for vitest 5.0.3 mention a nearby change: the browser-mode matcher `toHaveTextContent` now requires an exact match, and `toMatchTextContent` does a partial match. If your check is really `expect(el).toHaveTextContent('Save')` against "Save changes", that change explains the failure. Switch to `toMatchTextContent('Save')` to keep the partial match.
    
    If the locator itself is what fails, check which `getByText` you're calling. Vitest's browser `page.getByText` (Playwright-style) does a case-insensitive substring match unless you pass `{ exact: true }`. `@testing-library`'s `getByText` matches the full string by default, so it needs `/Save/` or `{ exact: false }` to match "Save changes". I haven't looked at your test code, so I don't know which case you're in.