vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Debugging tests via the extension is not working, something environmental

Open wnewbery opened this issue 3 months ago • 3 comments

Describe the bug

Using even the https://github.com/vitest-dev/vitest/tree/main/examples/basic everything works, except trying to debug in the extension. Be it the "testing" sidebar or "Debug test at Cursor" in a source file.

This would seem to be a local environmental issue, but the error is less than helpful and seems to be specific to this extension. Debugging in VSCode as a launch profile using npm run test:run command works perfectly, tests complete, breakpoints in ts files, etc. Node in the terminal path is 24.11.0.

Interestingly I only saw the "This is a bug in Vitest. Please, open an issue with reproduction." on the example test, and only one of the example files at that. But I saw "No task result for "suite.test.ts", ignoring" output and "No test suite found in file" UI in every project I tried to run debug tests on.

Debug Tests:

Image

But a non-debug "Run Tests"

Image

### Reproduction

https://github.com/vitest-dev/vitest/tree/main/examples/basic

### Output

```shell
Debug tests


[INFO 2:22:50 PM] [v0.0.0] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 2:22:51 PM] [API] Resolving configs: basic/vite.config.ts
[INFO 2:22:53 PM] [API] Running Vitest v4.0.8 (basic/vite.config.ts) with "C:\nvm4w\nodejs\node.EXE C:/Users/William/.vscode/extensions/vitest.explorer-1.32.1/dist/worker.js"
[INFO 2:22:54 PM] [API] Watching vite.config.ts
[INFO 2:22:54 PM] [VSCODE] Watching basic with pattern **/*
[INFO 2:22:54 PM] [API] Collecting tests: test/basic.test.ts, test/suite.test.ts
[INFO 2:22:58 PM] [DEBUG] Starting debugging session C:\nvm4w\nodejs\node.EXE
[INFO 2:22:59 PM] [DEBUG] Debugging started
[2:22:59 PM] [VSCODE] Ignoring file: node_modules\.vite-temp\vite.config.ts.timestamp-1762870979727-00a02e27f03048.mjs
[INFO 2:22:59 PM] Running all tests in basic
[2:22:59 PM] Starting a test run because test/basic.test.ts test/suite.test.ts triggered a watch rerun event
[2:22:59 PM] Enqueuing "Math.sqrt()"
[2:22:59 PM] Enqueuing "Squared"
[2:22:59 PM] Enqueuing "JSON"
[2:22:59 PM] Enqueuing "foo"
[2:22:59 PM] Enqueuing "bar"
[2:22:59 PM] Enqueuing "snapshot"
[2:22:59 PM] [VSCODE] File deleted: node_modules\.vite-temp\vite.config.ts.timestamp-1762870979727-00a02e27f03048.mjs
[INFO 2:23:00 PM] [Worker] Debugger attached.
[Error 2:23:00 PM] Error in D:/vitest-4.0.8/examples/basic/test/basic.test.ts Error: Vitest failed to find the current suite. This is a bug in Vitest. Please, open an issue with reproduction.
    at assert (file:///D:/vitest-4.0.8/examples/basic/node_modules/@vitest/runner/dist/index.js:525:9)
    at getCurrentSuite (file:///D:/vitest-4.0.8/examples/basic/node_modules/@vitest/runner/dist/index.js:555:2)
    at Object.<anonymous> (file:///D:/vitest-4.0.8/examples/basic/node_modules/@vitest/runner/dist/index.js:457:2)
    at chain (file:///D:/vitest-4.0.8/examples/basic/node_modules/@vitest/runner/dist/chunk-tasks.js:9:14)
    at D:/vitest-4.0.8/examples/basic/test/basic.test.ts:6:1
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at VitestModuleEvaluator.runInlinedModule (file:///d:/vitest-4.0.8/examples/basic/node_modules/vitest/dist/module-evaluator.js:174:4)
    at VitestModuleRunner.directRequest (file:///d:/vitest-4.0.8/examples/basic/node_modules/vite/dist/node/module-runner.js:1146:59)
    at VitestModuleRunner.cachedRequest (file:///d:/vitest-4.0.8/examples/basic/node_modules/vite/dist/node/module-runner.js:1053:73)
    at VitestModuleRunner.import (file:///d:/vitest-4.0.8/examples/basic/node_modules/vite/dist/node/module-runner.js:1014:10)
[2:23:00 PM] Marking "basic.test.ts" as failed with 1 errors
[2:23:00 PM] Marking "basic.test.ts" as failed with 1 errors
[INFO 2:23:00 PM] [Worker] Waiting for the debugger to disconnect...
[2:23:00 PM] No task result for "suite.test.ts", ignoring
[2:23:00 PM] Marking "suite.test.ts" as failed with 1 errors
[2:23:00 PM] Ending test run 
[2:23:00 PM] Test run promise is finished, the queue is 0
[2:23:00 PM] [API] Vitest WebSocket connection closed, cannot call RPC anymore.
[2:23:00 PM] Ending test run <none>
[2:23:00 PM] Disposing test runner
[2:23:00 PM] Ending test run <none>
[2:23:00 PM] [VSCODE] Ignoring file: node_modules\.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json


Run Tests (working)


[INFO 2:24:54 PM] Running all tests in basic
[2:24:54 PM] Starting a test run because test/basic.test.ts test/suite.test.ts triggered a watch rerun event
[2:24:55 PM] No task result for "suite.test.ts", ignoring
[2:24:55 PM] No task result for "suite name", ignoring
[2:24:55 PM] Enqueuing "foo" because it was just collected
[2:24:55 PM] Enqueuing "bar" because it was just collected
[2:24:55 PM] Enqueuing "snapshot" because it was just collected
[2:24:55 PM] No errors found for "suite.test.ts"
[2:24:55 PM] No task result for "basic.test.ts", ignoring
[2:24:55 PM] Enqueuing "Math.sqrt()" because it was just collected
[2:24:55 PM] Enqueuing "Squared" because it was just collected
[2:24:55 PM] Enqueuing "JSON" because it was just collected
[2:24:55 PM] No errors found for "basic.test.ts"
[2:24:55 PM] No errors found for "suite name"
[2:24:55 PM] Marking "foo" as passed
[2:24:55 PM] Marking "bar" as passed
[2:24:55 PM] Marking "snapshot" as passed
[2:24:55 PM] No errors found for "suite.test.ts"
[2:24:55 PM] Marking "Math.sqrt()" as passed
[2:24:55 PM] Marking "Squared" as passed
[2:24:55 PM] Marking "JSON" as passed
[2:24:55 PM] No errors found for "basic.test.ts"
[2:24:55 PM] Ending test run 
[2:24:55 PM] Test run promise is finished, the queue is 0
[2:24:55 PM] [VSCODE] Ignoring file: node_modules\.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json


Command line `npm run test:run`


PS D:\vitest-4.0.8\examples\basic> npm run test:run

> test:run
> vitest run


 RUN  v4.0.8 D:/vitest-4.0.8/examples/basic

 ✓ test/suite.test.ts (3 tests) 3ms
 ✓ test/basic.test.ts (3 tests) 3ms

 Test Files  2 passed (2)
      Tests  6 passed (6)
   Start at  14:34:05
   Duration  191ms (transform 55ms, setup 0ms, collect 81ms, tests 7ms, environment 0ms, prepare 10ms)

Extension Version

1.32.1

Vitest Version

4.0.8

Validations

wnewbery avatar Nov 11 '25 14:11 wnewbery

I'm running into this issue myself, was working on a custom reporter and thought it was my code (Ok may still be, but...). I too can get F5 working, and the tests run fine if not debugged. Debugging is completely broken.

Extension: 1.36.0 Vitest: 4.0.14

dotnetprofessional avatar Dec 06 '25 17:12 dotnetprofessional

Looking into it a bit more, it doesn't seem like vitest v4 is working with the extension. In v1.28.0 I don't see any tests show up, then v1.28.1 I do, but it exhibits this issue and continues to. I have custom code that relies on the v4 API so can't easily downgrade.

I've tried with a simple vitest too and that's not working either. Here are the logs:

[INFO 10:42:03 AM] [DECOR] Decorations for d:\private\LiveDoc\packages\livedoc-vitest_src\test\Sample\PureVitest.Spec.ts are already cached. Displaying them. [INFO 10:42:03 AM] [DEBUG] Starting debugging session C:\Program Files\nodejs\node.EXE [INFO 10:42:03 AM] [DEBUG] Debugging started [10:42:04 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite-temp\vitest.config.vscode.ts.timestamp-1765046524324-7b8793b90ca7b.mjs [INFO 10:42:04 AM] Running 1 file(s) with name pattern: ^\s?Pure Vitest Tests Counter tests [10:42:04 AM] Starting a test run because packages/livedoc-vitest/_src/test/Sample/PureVitest.Spec.ts triggered a watch rerun event [10:42:04 AM] Enqueuing "should increment counter" [10:42:04 AM] Enqueuing "should start fresh each test" [10:42:04 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json [10:42:04 AM] [VSCODE] File deleted: packages\livedoc-vitest\node_modules.vite-temp\vitest.config.vscode.ts.timestamp-1765046524324-7b8793b90ca7b.mjs [INFO 10:42:04 AM] [Worker] Debugger attached. [INFO 10:42:05 AM] [DECOR] Reset all decorations. [10:42:05 AM] No task result for "PureVitest.Spec.ts", ignoring [10:42:05 AM] Marking "PureVitest.Spec.ts" as failed with 1 errors [10:42:05 AM] Ending test run packages/livedoc-vitest/_src/test/Sample/PureVitest.Spec.ts [10:42:05 AM] Test run promise is finished, the queue is 0 [INFO 10:42:05 AM] [Worker] Waiting for the debugger to disconnect... [10:42:05 AM] [API] Vitest WebSocket connection closed, cannot call RPC anymore. [10:42:05 AM] Ending test run [10:42:05 AM] Disposing test runner [10:42:05 AM] Ending test run [10:42:05 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json [INFO 10:42:32 AM] [DECOR] Decorations for d:\private\LiveDoc\packages\livedoc-vitest_src\test\Sample\PureVitest.Spec.ts are already cached. Displaying them.

When running my custom wrappers for describe/it etc. Again everything works well outside of debug including highlighting passed tests in code and navigating to the code too. Just breaks everything when trying to debug.

[INFO 10:48:01 AM] [DECOR] Decorations for d:\private\LiveDoc\packages\livedoc-vitest_src\test\Sample\PureVitest.Spec.ts are already cached. Displaying them. [INFO 10:48:01 AM] [DEBUG] Starting debugging session C:\Program Files\nodejs\node.EXE [INFO 10:48:01 AM] [DEBUG] Debugging started [10:48:02 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite-temp\vitest.config.vscode.ts.timestamp-1765046882291-4bdd57f75168e.mjs [INFO 10:48:02 AM] Running 1 file(s) with name pattern: ^\s?Feature: Account Holder withdraws cash

Account Holders should be able to withdraw cash at any of the
companies ATMs\.

Rules:
\* Account Holders should have a valid keycard
\* Have sufficient available funds
\* The ATM has the necessary funds
 Scenario: Account has sufficient funds

[10:48:02 AM] Starting a test run because packages/livedoc-vitest/_src/test/Sample/Example.Spec.ts triggered a watch rerun event [10:48:02 AM] Enqueuing "Given the account holders account has the following: | account | 12345 | | balance | 100 | | status | valid | " [10:48:02 AM] Enqueuing " and the machine contains '1000' dollars" [10:48:02 AM] Enqueuing "When the Account Holder requests '20' dollars" [10:48:02 AM] Enqueuing "Then the ATM should dispense '20' dollars" [10:48:02 AM] Enqueuing " and the account balance should be '80' dollars" [10:48:02 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json [10:48:02 AM] [VSCODE] File deleted: packages\livedoc-vitest\node_modules.vite-temp\vitest.config.vscode.ts.timestamp-1765046882291-4bdd57f75168e.mjs [INFO 10:48:02 AM] [Worker] Debugger attached. [INFO 10:48:03 AM] [DECOR] Reset all decorations. [10:48:03 AM] No task result for "Example.Spec.ts", ignoring [10:48:03 AM] Marking "Example.Spec.ts" as failed with 1 errors [INFO 10:48:03 AM] [Worker] Waiting for the debugger to disconnect... [10:48:03 AM] Ending test run packages/livedoc-vitest/_src/test/Sample/Example.Spec.ts [10:48:03 AM] Test run promise is finished, the queue is 0 [10:48:03 AM] [API] Vitest WebSocket connection closed, cannot call RPC anymore. [10:48:03 AM] Ending test run [10:48:03 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json [10:48:03 AM] Disposing test runner [10:48:03 AM] Ending test run

This is the log I see when starting up VSCode: [INFO 10:53:19 AM] [v0.0.0] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace. [INFO 10:53:19 AM] [API] Using user root config: d:\private\LiveDoc\packages\livedoc-vitest\vitest.config.vscode.ts [INFO 10:53:22 AM] [API] Resolving configs: livedoc-vitest/vitest.config.vscode.ts [INFO 10:53:27 AM] [API] Running Vitest v4.0.14 (livedoc-vitest/vitest.config.vscode.ts) with "C:\Program Files\nodejs\node.EXE C:/Users/garrm/.vscode/extensions/vitest.explorer-1.36.0/dist/worker.js" [INFO 10:53:28 AM] [Worker] 🔵 [VITEST CONFIG] Using vitest.config.vscode.ts - NO custom reporte [INFO 10:53:28 AM] [API] Watching packages\livedoc-vitest\vitest.config.vscode.ts [INFO 10:53:28 AM] [VSCODE] Watching LiveDoc with pattern */ [INFO 10:53:28 AM] [API] Collecting tests: packages/livedoc-vitest/_src/test/Sample/Example.Spec.ts [10:53:28 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite-temp\vitest.config.vscode.ts.timestamp-1765047208455-b286be59de49f.mjs [Error 10:53:29 AM] Error in D:/private/LiveDoc/packages/livedoc-vitest/_src/test/Sample/Example.Spec.ts No test suite found in file D:/private/LiveDoc/packages/livedoc-vitest/_src/test/Sample/Example.Spec.ts [10:53:29 AM] [VSCODE] Ignoring file: packages\livedoc-vitest\node_modules.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json [10:53:29 AM] [VSCODE] File deleted: packages\livedoc-vitest\node_modules.vite-temp\vitest.config.vscode.ts.timestamp-1765047208455-b286be59de49f.mjs [INFO 10:53:41 AM] [API] Collecting tests: packages/livedoc-vitest/_src/test/Sample/Tutorial/Tutorial.Spec.ts [Error 10:53:41 AM] Error in D:/private/LiveDoc/packages/livedoc-vitest/_src/test/Sample/Tutorial/Tutorial.Spec.ts No test suite found in file D:/private/LiveDoc/packages/livedoc-vitest/_src/test/Sample/Tutorial/Tutorial.Spec.ts

dotnetprofessional avatar Dec 06 '25 18:12 dotnetprofessional

Duplicate of https://github.com/vitest-dev/vscode/issues/548 probably

parched avatar Dec 08 '25 08:12 parched