vitest-dev / vitest-dev/vscode
Phantom tests appearing in test explorer based on variable name
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 924
- Forks
- 122
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 6
Description
Describe the bug
Any method invocation beginning with the string test* is being incorrectly considered a test and pulled into test-explorer at parsing stage.
Minimal repro:
repro.test.ts
testAbc123('this-shows-up-in-test-explorer');
testify('this-too-shows-up-in-test-explorer');
itAbc123('this-does-not-show-up-in-test-explorer');
Result:
If you intend to submit a PR for this issue, tell us in the description. Thanks!
I will update if I have time to address this myself.
Also, I can provide a full repro project later in the week if needed, please let me know.
Expected behavior
Only tests should show up in the test explorer. This could likely be solved by restricting the regex pattern.
Reproduction
Real code sample:
describe('Directory (Profile) Controller', () => {
beforeAll(() => {
({ testApp, jwksMock } = setupRouter());
testApp.use('/', DirectoryRouter);
});
});
- Create a file that will be discovered by vitest
- Add code like the above
- Save and refresh the vscode test explorer
Output
[6:18:20 PM] [VSCODE] Flushing 1 changed items
[INFO 6:18:20 PM] [API] Collecting tests: src/__tests__/controllers/repro.int.test.ts [api:integration]
[6:18:20 PM] [API] Spawning on-demand process...
[6:18:20 PM] [API] Filtering projects: api:integration
[INFO 6:18:20 PM] [API] Running Vitest v4.1.4 (api/vitest.config.ts) with "/home/me/.nvm/versions/node/v23.9.0/bin/node /home/me/.vscode-server/extensions/vitest.explorer-1.50.1/dist/worker.js"
[6:18:21 PM] [API] Vitest WebSocket connection closed, cannot call RPC anymore.
[6:18:21 PM] [API] On-demand process finished in 314ms
Extension Version
1.50.1
Vitest Version
4.1.4
Validations
- Check that you are using the latest version of the extension
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the test-discovery parsing stage used by the VS Code test explorer and reproduce the issue with repro.test.ts, using the provided testAbc123, testify, and itAbc123 calls. Inspect the regex or matching rule that identifies test invocations; done means only actual test calls appear in the explorer while the non-test examples do not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- devtools, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100