I am writing a Typescript library. Unit tests are also written in Typescript using the Mocha framework. I would like to run unit tests directly without compilation in javascript. This works with this command:
./node_modules/mocha/bin/mocha ./test/*.test.ts --require ts-node/register
I am trying to debug unit test from Visual Studio code with the following startup settings:
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"--require",
"ts-node/register",
"${workspaceRoot}/test/*.test.ts"
],
"internalConsoleOptions": "openOnSessionStart"
}
That way I can debug Mocha itself from VS Code, but not unit tests. Mocha generates separate processes for tests, and the debugger cannot automatically join child processes.
What is the correct way to debug Typescript unit tests from Visual Studio code?