title: How to debug unit tests written in Typescript with Mocha from Visual Studio Code
body: <p>I write a Typescript library. The unit tests are also written in Typescript using Mocha framework. I'd like to execute the unit tests directly without compiling into javascript.
  This works with this command:</p>
  
  <pre><code>./node_modules/mocha/bin/mocha  ./test/*.test.ts  --require ts-node/register
  </code></pre>
  
  <p>I try to debug the unit test from Visual Studio Code with the following launch settings: </p>
  
  <pre><code>{
      "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"
  }
  </code></pre>
  
  <p>This way I can debug Mocha itself from VS Code, but not the unit tests. Mocha spawns separate processes for the tests and the debugger can not automatically attach to the child processes.</p>
  
  <p>What is the right way to debug Typescript unit tests from Visual Studio Code?</p>