title: Breakpoints in Visual Studio Code not hit when debugging mocha tests
body: <p>I'm using Mocha (and Chai) for my unit tests for a NodeJS module and want to debug it in Visual Studio code. I have a TypeScript file in the <code>test</code> subfolder with some tests. VScode generates the .js and .map file in the out dir (via tsc watch mode task). My tsconfig.json file contains these settings:</p>
  
  <pre><code>{
      "compilerOptions": {
          "compileOnSave": true,
          "module": "commonjs",
          "target": "es6",
          "outDir": "out",
          "removeComments": true,
          "noImplicitAny": true,
          "sourceMap": true,
          "inlineSources": true,
          "isolatedModules": false,
          "allowSyntheticDefaultImports": true,
          "experimentalDecorators": true
      },
      "include": [
          "src/**/*", "parser/**/*", "test/**/*"
      ],
      "exclude": [
          "node_modules",
          ".vscode-test"
      ]
  }
  </code></pre>
  
  <p>and the out dir contains 3 subdirs for the 3 includes. All fine so far.</p>
  
  <p>I can run my tests using this command:</p>
  
  <pre><code>mocha --compilers ts:ts-node/register,tsx:ts-node/register
  </code></pre>
  
  <p>outside of vscode. Then I ran this code with the <code>--debug-brk</code> switch and attached vscode to it. This works, but no breakpoint is hit. The configuration in launch.json for that is:</p>
  
  <pre><code>    {
          "name": "Attach",
          "type": "node",
          "request": "attach",
          "port": 5858,
          "address": "localhost",
          "restart": false,
          "sourceMaps": true,
          "outDir": null,
          "localRoot": "${workspaceRoot}",
          "remoteRoot": null
      }
  </code></pre>
  
  <p>Ideally, I'd like to have a run config so that I don't need to run mocha manually. With these settings I can at least run the tests:</p>
  
  <pre><code>    {
          "name": "Mocha",
          "type": "node",
          "request": "launch",
          "cwd": "${workspaceRoot}",
          "preLaunchTask": "tsc",
          "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
          "args": [ "--no-timeouts", "--colors", "${workspaceRoot}/out/test/**/*.js" ],
          "stopOnEntry": true,
          "runtimeExecutable": null,
          "env": {
             "NODE_ENV": "testing"
          }
          "sourceMaps": true
      }
  </code></pre>
  
  <p>but still, no breakpoint is hit.</p>
  
  <p>What is required to make at least one of the 2 scenarios work?</p>
  
  <p><strong>Update</strong>: meanwhile I found by accident that breakpoints start working when you add a <code>debugger;</code> command somewhere in the test code and set at least one fresh breakpoint <strong>after it stopped</strong> on <code>debugger;</code>. After that all following breakpoints in this single file work as expected. Looks almost like a bug to me.</p>