-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot Debug Test Files with --inspect-brk
Flag
#1867
Comments
See: https://vitest.dev/guide/debugging.html#vscode Note: This was the only method I could get to work - the normal node inspector on the command line is not ready. See: vitest-dev/vitest#1867
Yes, I am aware of this. The support is currently only forwarding the flag to the Node process, where the main issue is that Node does not support inspecting workers yet. |
Same issue here. Also not able to attach to the debug process in VSCode using the recommended launch config. Node 14.19.0 / npm 8.6.0 / Vitest 0.22.1 @alexlafroscia can you share the launch config that worked for you? will see if it resolves the issue |
As far as I know I haven't used a launch config to debug tests; the Vitest plugin for VSCode is excellent, and I use that a bunch. I also use the JavaScript Debug Terminal in VSCode,, which does some magic under-the-hood to ensure that all Node processes are launched in |
Does #2772 get us any closer to being able to support a more "typical" Node debugging story? I'm imagining a situation where, if My thought is that if vitest/packages/vitest/src/node/pool.ts Lines 28 to 30 in 0280825
|
I've been able to step into Vitest test cases with debugger even when threads are enabled. Not sure if .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "inspect vitest",
"type": "node",
"request": "launch",
"autoAttachChildProcesses": true,
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/vitest/vitest.mjs"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
} Debugger on Chrome Devtools works just as well. Simply run |
I think it's the What I'm looking for is a command to document for my team so they can debug tests without using VSCode. Many of the developers do use it, but we also are not making VSCode a requirement for working on our project, so I'm hoping something can be done within Vitest to allow for debugging in an editor-agnostic way. |
The VSCode's But by modifying the sources so that |
I upgraded to |
Describe the bug
With the new
--inspect
and--inspect-brk
flags, I expected to have a way for Vitest to debug test files without a tool like VSCode or IntelliJ. Unfortunately, that was not the case!With a
debugger
in my test file, the following command does not pause on thedebugger
statementA
debugger
in my config file is paused on just fine, but ones in tests (which are more likely what folks want to debug) are not respected.The commit that introduces the flags doesn't specifically say that the flag does or doesn't allow for debugging tests, so I suppose this expectation is an assumption on my part, but I believe that this flag not allowing child processes to be debugged would surprise users.
Adding the
--threads false
configuration was an attempt to avoid spawning child processes, like Jest's--runInBand
, but that doesn't resolve the issue.The only way I have found to debug a test file is with a tool that automatically allows child processes to be debugged, such as
ndb
or the VSCode debugging tools (through their "launch" config or integrated JavaScript debugging terminal). While this is fine for some users (myself included!) I am not sure how to advise team members that do not use these tools on how to debug test files.Reproduction
This repo contains a reproduction environment, as well as instructions
https://github.com/alexlafroscia/__vitest-inspect-brk
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: