vitest-5-0-0-13-b
Claude Code's read-only tools, web search on, ludion sync off
Question
What separator does Vitest's testNamePattern use between suite and test names?
Answer key
- A correct answer says
- In `-t` / testNamePattern, nested suite and test names are joined with `>`.
- The stale answer
- Suite and test names in the -t full name are joined with a space.
Answer
It depends on the Vitest version. According to the current Vitest docs, `testNamePattern` (`-t` / `--testNamePattern`) is matched against the test's full name. That full name is the enclosing `describe` names plus the test name, joined with **` > `**, which is the same string the reporter prints. So a test `adds` inside `describe('math')` has the full name `math > adds`, and both `-t 'math > adds'` and `-t adds` match it.
The docs also say that before Vitest 5 the parts were joined with a **single space** (`math adds`) to match Jest. On older versions, write patterns with spaces instead. The option takes a string or a RegExp. I got this from the docs through search results and didn't open the pages myself, so check the docs for your version if the exact separator matters.
Sources:
- [vitest.dev – testNamePattern config](https://vitest.dev/config/testnamepattern)
- [vitest.dev – Test Filtering guide](https://vitest.dev/guide/filtering)
- [main.vitest.dev – testNamePattern](https://main.vitest.dev/config/testnamepattern)Grade
correct
The judge's reason: It states that current Vitest joins suite and test names with ` > ` and presents the space separator only as pre-Vitest 5 behavior, not as current.
Session log
Tool call: ToolSearch
{ "query": "select:WebSearch", "max_results": 1 }Tool output
{"type":"tool_reference","tool_name":"WebSearch"}Tool call: WebSearch
{ "query": "vitest testNamePattern full name separator suite test \" > \" space", "mode": "standard" }Tool output
Web search results for query: "vitest testNamePattern full name separator suite test " > " space" Links: [{"title":"vitest.dev","url":"https://vitest.dev/config/testnamepattern"},{"title":"docs.w3cub.com","url":"https://docs.w3cub.com/vitest/config/testnamepattern"},{"title":"main.vitest.dev","url":"https://main.vitest.dev/config/testnamepattern"},{"title":"Test Filtering","url":"https://vitest.dev/guide/filtering"},{"title":"docs.w3cub.com","url":"https://docs.w3cub.com/vitest/guide/filtering"},{"title":"main.vitest.dev","url":"https://main.vitest.dev/guide/filtering"},{"title":"This documentation covers Vitest v2 (old version). For the latest version, see","url":"https://v2.vitest.dev/guide/filtering"},{"title":"next.tangled.org","url":"https://next.tangled.org/vitest.dev/vitest/blob/v3/docs/guide/filtering.md"},{"title":"next.tangled.org","url":"https://next.tangled.org/vitest.dev/vitest/blob/v2/docs/guide/filtering.md"},{"title":"test suite","url":"https://v3.vitest.dev/advanced/api/test-suite"}] The current Vitest docs say `testNamePattern` matches against a test's full name, which is the enclosing suite names and the test name joined with ` > `, the same string the reporter shows. So `-t 'math > adds'` and `-t adds` both match a test named `adds` inside `describe('math')`. The pattern is matched against the test's full name, and the docs give that `math > adds` example. There's a version difference to note. The docs warn that before Vitest 5, the segments were joined with a single space (math adds) to mirror Jest. So on pre-5 releases, the separator is a space, not ` > `. The docs also say the flag accepts a string or RegExp. The CLI flag is `-t` or `--testNamePattern`, and this can be helpful when you want to filter by the name defined within a file rather than the filename itself. REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.Agent
It depends on the Vitest version. According to the current Vitest docs, `testNamePattern` (`-t` / `--testNamePattern`) is matched against the test's full name. That full name is the enclosing `describe` names plus the test name, joined with **` > `**, which is the same string the reporter prints. So a test `adds` inside `describe('math')` has the full name `math > adds`, and both `-t 'math > adds'` and `-t adds` match it. The docs also say that before Vitest 5 the parts were joined with a **single space** (`math adds`) to match Jest. On older versions, write patterns with spaces instead. The option takes a string or a RegExp. I got this from the docs through search results and didn't open the pages myself, so check the docs for your version if the exact separator matters. Sources: - [vitest.dev – testNamePattern config](https://vitest.dev/config/testnamepattern) - [vitest.dev – Test Filtering guide](https://vitest.dev/guide/filtering) - [main.vitest.dev – testNamePattern](https://main.vitest.dev/config/testnamepattern)