feat: Add configurable test identifiers for static parsing #9235
+18
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
seeking feedback
This configures the test function names used by the AST parser.
When creating custom test context functions (for example:
testDbandtestNetwork), these are not discovered by tools like the vitest vscode extension. This means that the extension does not provide the on-off test icon in the gutter next to the test.This stage of the PR is incomplete and seeking feedback on the approach before moving further into writing unit tests, documentation, and/or adding the other strings to the configuration.
Resolves vitest-dev/vscode#649
Why
In my code base, we've created several custom test contexts:
testDb- Provides the DB connector and adds setup/teardown for that test.testNetwork- Provides a reference to msw and performs setup/teardown for the test.Unfortunately, these are not recognized by the vitest vscode extension, so we don't get the option to run the test as a one-off without running the entire suite. We also don't want to make these the default tests because it can be heavy to setup/teardown a DB for tests that do not need it.
Usage
In this example, the end user would just, optionally, add a new
astsection to their vitest configuration:Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.