Describe the bug
When a test uses using, and is defined with a function not named it, Vitest shows an unexpected it[2] entry in the Test Explorer. This seems to how esbuild transforms the code; setting esbuild.target in the vitest config to esnext appears to solve the problem.
This seems strange because the vitest doc states that esnext is the default, but in practice it doesn't seem to be.
I am filing in the Vitest-VS Code repo because when I call Vitest using the command line (npx vitest list), these entries are not returned. However, I did some light debugging and found that these entries are present when onCollected is handled (listener(file, collecting)). So the root cause of the issue would seem to be in Vitest (and possibly Vite itself or Rolldown), but Vitest's CLI is filtering it out successfully.
The File object provided by Vitest will have undefined location information (seemingly coming from somewhere around https://github.com/vitest-dev/vitest/blob/8e2108ddaec3c58501621fdd2d78929d87c383c8/packages/vitest/src/node/ast-collect.ts#L441 but I'm not familiar with thise codebase.
This issue can happen for every file with using in the tests, which can mean many instances.
The entries tend to disappear after running the containing suite, but will re-appear after manually refreshing the test explorer list.
Expected behavior
Using using does not lead to an it[2] entry in the test explorer.
Reproduction
This test file repros the issue in the browser test suite in this repo:
import { describe, test } from 'vitest'
describe('', (a) => {
test('', () => {
using x = 1;
})
})
That's the bare minimum, but it repros with more realistic test cases (e.g. ones with names). The issue is definitely any line with the pattern using x = y;.
Output
Cannot find location for "it[2]". Using "id" to sort instead.
Extension Version
1.50.8
Vitest Version
vitest/4.1.10 darwin-arm64 node-v24.11.0
Validations
Describe the bug
When a test uses
using, and is defined with a function not namedit, Vitest shows an unexpectedit[2]entry in the Test Explorer. This seems to how esbuild transforms the code; settingesbuild.targetin the vitest config toesnextappears to solve the problem.This seems strange because the vitest doc states that esnext is the default, but in practice it doesn't seem to be.
I am filing in the Vitest-VS Code repo because when I call Vitest using the command line (
npx vitest list), these entries are not returned. However, I did some light debugging and found that these entries are present whenonCollectedis handled (listener(file, collecting)). So the root cause of the issue would seem to be in Vitest (and possibly Vite itself or Rolldown), but Vitest's CLI is filtering it out successfully.The
Fileobject provided by Vitest will have undefined location information (seemingly coming from somewhere around https://github.com/vitest-dev/vitest/blob/8e2108ddaec3c58501621fdd2d78929d87c383c8/packages/vitest/src/node/ast-collect.ts#L441 but I'm not familiar with thise codebase.This issue can happen for every file with
usingin the tests, which can mean many instances.The entries tend to disappear after running the containing suite, but will re-appear after manually refreshing the test explorer list.
Expected behavior
Using
usingdoes not lead to anit[2]entry in the test explorer.Reproduction
This test file repros the issue in the browser test suite in this repo:
That's the bare minimum, but it repros with more realistic test cases (e.g. ones with names). The issue is definitely any line with the pattern
using x = y;.Output
Extension Version
1.50.8
Vitest Version
vitest/4.1.10 darwin-arm64 node-v24.11.0
Validations