vitest-dev / vitest-dev/vscode

Phantom tests appearing in test explorer based on variable name

Open Beginner friendly
#776 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage
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:

Image

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);
  });
});
  1. Create a file that will be discovered by vitest
  2. Add code like the above
  3. 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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.