Skip to content

Debugging Browser Tests doesn't work in project setupsΒ #691

@Alanoll

Description

@Alanoll

Describe the bug

I'm having an issue debugging into a test when run in browser mode and my projects are setup using projects.

The test runs, and reports a success result, but never breaks into the debugger. I eventually after a timeout recieve an error saying Cannot connect to the target at localhost:9229: Could not connect to debug target at http://localhost:9229: Could not find debuggable target from VSCode.

Image

This may be related to #689 as it's workspace/project related, but didn't report anything about debugging.

Reproduction

I've narrowed it down to something to do with the Vitest Project setup.

https://github.com/Alanoll/vitest-vscode-project-repro

The repo currently triggers the bug.
If you modify the vite.config.mts at the root and comment line 40, it will use a non-project configuration and work.

Output

[INFO 10:03:57 PM] [API] Resolving configs: vitest-repro/vite.config.mts
[INFO 10:03:57 PM] [API] Running Vitest v4.0.14 (vitest-repro/vite.config.mts) with "C:\Program Files\nodejs\node.EXE C:/Users/***/.vscode/extensions/vitest.explorer-1.34.0/dist/worker.js"
[INFO 10:03:57 PM] [API] Watching vite.config.mts
[INFO 10:03:57 PM] [VSCODE] Watching vitest-repro with pattern **/*
[10:03:57 PM] [VSCODE] Ignoring file: node_modules\.vite-temp\vite.config.mts.timestamp-1764475437624-87ff322675c9a.mjs
[10:03:57 PM] [VSCODE] File deleted: node_modules\.vite-temp\vite.config.mts.timestamp-1764475437624-87ff322675c9a.mjs
[INFO 10:03:57 PM] [API] Collecting tests: projects/project1/src/math.test.ts [project1 (chromium)]
[INFO 10:04:17 PM] [DEBUG] Starting debugging session C:\Program Files\nodejs\node.EXE
[INFO 10:04:18 PM] [DEBUG] Debugging started
[10:04:18 PM] [VSCODE] Ignoring file: node_modules\.vite-temp\vite.config.mts.timestamp-1764475458653-cbf064c83e3b1.mjs
[INFO 10:04:18 PM] Running 1 file(s) with name pattern: ^\s?addition add$
[10:04:18 PM] Starting a test run because projects/project1/src/math.test.ts triggered a watch rerun event
[10:04:18 PM] Enqueuing "add"
[10:04:19 PM] [VSCODE] File deleted: node_modules\.vite-temp\vite.config.mts.timestamp-1764475458653-cbf064c83e3b1.mjs
[10:04:19 PM] No task result for "math.test.ts [project1 (chromium)]", ignoring
[10:04:19 PM] No task result for "addition", ignoring
[10:04:19 PM] Enqueuing "add" because it was just collected
[10:04:19 PM] Ignore "sum" during collection
[10:04:19 PM] Ignore "skipped" during collection
[10:04:19 PM] Ignore "todo" during collection
[10:04:19 PM] Ignore "async task" during collection
[10:04:19 PM] Ignore "async task 0.5s" during collection
[10:04:19 PM] Ignore "async task 1s" during collection
[10:04:19 PM] Ignore "long task" during collection
[10:04:19 PM] No errors found for "math.test.ts [project1 (chromium)]"
[10:04:19 PM] No errors found for "addition"
[10:04:19 PM] Marking "add" as passed
[10:04:19 PM] Marking "sum" as skipped
[10:04:19 PM] Marking "skipped" as skipped
[10:04:19 PM] Marking "todo" as skipped
[10:04:19 PM] Marking "async task" as skipped
[10:04:19 PM] Marking "async task 0.5s" as skipped
[10:04:19 PM] Marking "async task 1s" as skipped
[10:04:19 PM] Marking "long task" as skipped
[10:04:19 PM] No errors found for "math.test.ts [project1 (chromium)]"
[10:04:19 PM] Ending test run projects/project1/src/math.test.ts
[10:04:19 PM] Test run promise is finished, the queue is 0
[10:04:19 PM] [API] Vitest WebSocket connection closed, cannot call RPC anymore.
[10:04:19 PM] Ending test run <none>
[10:04:19 PM] Disposing test runner
[10:04:19 PM] Ending test run <none>
[10:04:19 PM] [VSCODE] Ignoring file: node_modules\.vite\vitest\da39a3ee5e6b4b0d3255bfef95601890afd80709\results.json

Extension Version

1.34.0

Vitest Version

4.0.14

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p4-importantViolate documented behavior or significantly improves performance (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions