vscode icon indicating copy to clipboard operation
vscode copied to clipboard

customize list of identifiers in ast collection

Open luxass opened this issue 5 months ago • 3 comments

Clear and concise description of the problem

The AST collection currently uses a hardcoded list of test function identifiers ['it', 'test', 'describe', 'suite'].

This prevents proper test discovery when using extended test contexts or custom test function names that don't match these predefined identifiers.

I will gladly open a PR for this, if this is a welcoming change :)

Suggested solution

Add support for customizing the list of identifiers

Alternative

No response

Additional context

No response

Validations

luxass avatar Aug 09 '25 09:08 luxass

Ideally, we want to support this natively without user configuring the names. The code for parsing is now in Vitest: https://github.com/vitest-dev/vitest/blob/eebafb5c3ca295373d517a136b2d643a9353752f/packages/vitest/src/node/core.ts#L748

sheremet-va avatar Sep 04 '25 01:09 sheremet-va

@sheremet-va can you provide a little more context on this?

It looks like experimental_parseSpecifications still just parse it and test out of a test file. If we define custom test context functions in our project (in my case testDb, and testNetwork), how can we tell vitest how to recognize them as tests?

Are you suggesting that the names of these would be configured in the vitest.config in the project, and then automatically pulled into the vscode extension if it's updated to use experimental_parseSpecifications?

jgillick avatar Dec 11 '25 20:12 jgillick

After digging through the code more, I think I understand what @sheremet-va is recommending.

The vscode extension already uses experimental_parseSpecifications for parsing in projects that are using vitest 4.0+. So the change would be to vitest, not the extension.

I've submitted a quick prototype of what this might look like to the project: https://github.com/vitest-dev/vitest/pull/9235

jgillick avatar Dec 11 '25 22:12 jgillick