I manage to hit my breakpoint, but I have a few problems.
--compilers jsx:babel-register and renaming from .js to .jsx and the breakpoint just doesn't get hit any more.Mocha options that seem to stop it working completely:
--require babel-register
--require test/util/dom.js
--require expect
--compilers jsx:babel-register
Launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "request": "launch",
      "name": "Debug Mocha Test",
      "type": "node",
      "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
      "args": [
        "test/**/*.spec.js", //I need to get this working with .jsx files
        "--require", "babel-register"
        ],
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": null,
      "env": { }
    }
  ]
}
Turns out that this is a bug with the node debugger. I fixed all of the problems by changing:
"type": "node" to "type": "node2".
Launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "request": "launch",
      "name": "Debug Mocha Test",
      "type": "node2",
      "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
      "args": [
        "test/**/*.spec.jsx",
        "--colors", "--no-timeouts"
        ],
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": null,
      "env": { }
    }
  ]
}
mocha.opts:
--require babel-register
--require test/util/dom.js
--require expect
--compilers jsx:babel-register
Answer taken from weinand.
You also need a .babelrc file in your root app with the "retainLines": true. Here is my .babelrc file for example:
{
    "presets": [
        "es2015",
        "stage-2",
        "react"
    ],
    "plugins": [
        "transform-es2015-modules-umd"
    ],
        "retainLines": true
}
If you get bad option: --inspect=..., try and installing a newer version of node.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With