-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Add configurable test identifiers for static parsing #9235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
This seems like a bad developer experience. I wonder if we should instead define a convention for these names and respect it when parsing. |
|
That's another possibility. Honestly, when I ran into this problem, I was hoping that I could just name the function |
I think it's good enough. We just ignore all the functions that don't follow |
|
@sheremet-va thank you for your feedback. I've updated the PR to instead look for functions name ending in "Test". The current check is pretty basic, but it could be updated to a regex expression, if we want. I haven't fully tested this yet, and wanted to first get a temperature check before continuing. |
I don't think this fixes your use cases:
Both of them start with |
Indeed. I was just planning to change my functions to match this convention, but I can also update the PR to do both. |
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:.