Rigadoon
Rigadoon9mo ago

Debug all tests in VSCode

Hi everyone. I was hoping to use the equivalent of "deno test" in such a way that I can set a breakpoint in VSCode and run all test with debug. The effect would be that hitting any breakpoint in any test pauses at that line of execution. Is this possible?
4 Replies
Deno AI Helper
Deno AI Helper9mo ago
According to the documentation, currently, Deno only supports the “run” test capability. The debug run mode is planned to be added in the future. Therefore, as of now, you cannot directly debug tests using breakpoints in VSCode. However, you can use the built-in VSCode debugger to debug your Deno programs. You can generate a configuration by going to the Run and Debug panel, clicking create a launch.json file and selecting Deno option from the available debugger options. This will allow you to set breakpoints and debug your code. Remember, this is not specific to tests and will work for any Deno program. For debugging tests specifically, we'll have to wait for the debug run mode to be added in the future. 🦕
Leokuma
Leokuma9mo ago
You will need a launch.json like this:
{
"configurations": [
{
"type": "node",
"name": "Deno attach",
"port": 9229,
"request": "attach",
}
]
}
{
"configurations": [
{
"type": "node",
"name": "Deno attach",
"port": 9229,
"request": "attach",
}
]
}
Then run:
deno test --inspect-wait
deno test --inspect-wait
Deno will then wait for you to connect the inspector before running the tests. Now you start the debugging session in VSCode by hitting F5 or clicking play
No description
Rigadoon
Rigadoon9mo ago
Thanks Leokuma. I've done this but not had success. What happens is it runs the first test and then if F5 continue, it never moves on to the second test. Have you had success? I can keep hitting "Debug attach" and it incrementally moves on one by one, but what I was looking for was a way to run all 300+ of my unit tests and only halt when one hits my breakpoint of interest.
Leokuma
Leokuma9mo ago
Accross different files I think you do have to restart the debugger. You can click the green "↩️" icon For tests in the same file it should hit all the breakpoints without restarting the debugger IDK a way around that. I think Deno spawns a new process to test each file If it helps, you can also provide a specific file or folder to be tested by deno test