
While working on another article, I needed to flush out some ideas using unit test. In particular I needed to view some variables in flight, so I needed a debugger.
After search for a bit I ran across this documentation on .Vitest Debugging in Visual Studio Code
Creating a .vscode/launch.json
configuration file and adding the following information.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
Just ensure that you have your test file opened and currenctly selected in
Visual Studio Code (vscode)
and click the debug button, and you’re off to the races.