customize list of identifiers in ast collection
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
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
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 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?
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