Vscode: Debug CRA Tests stopped working on v1.19

Created on 15 Dec 2017  ·  3Comments  ·  Source: microsoft/vscode

  • VSCode Version: 1.19
  • OS Version: Windows 10

Steps to Reproduce:

  1. Setup a launch configuration as described here: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-tests-in-visual-studio-code
  2. Fire the debugger with F5 or play on the debugging panel
  3. The debugger doesn't start the test scripts and eventually fires a timeout
  4. Rollback to version 1.18
  5. Follow steps 1-2
  6. The debugger starts the test scripts and properly attaches to the debugger

Note: the changelog for 1.19 mentions new additions on the debugging experience: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-tests-in-visual-studio-code

I'll post the same issue on Create React App since it seems to be tightly related:
https://github.com/facebookincubator/create-react-app/issues/3602


Reproduces without extensions: Yes

debug

Most helpful comment

@amadeogallardo that configuration should work fine for all versions of VS Code.

All 3 comments

The launch config at https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-tests-in-visual-studio-code is wrong (but it worked by accident because VS Code had a bug in previous versions).

  • don't use an "--inspect-brk" since VS Code inserts that automatically based on the node.js version being used.
  • "test" is not a runtime argument and belongs into the "args" array.

Just try this:

{
      "name": "Debug CRA Tests",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
      "args": [
        "test",
        "--runInBand",
        "--no-cache",
        "--env=jsdom"
      ],
      "cwd": "${workspaceRoot}",
      "protocol": "inspector",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    }

Thanks for the swift response @weinand. The configuration above worked fine with VS Code 1.19.
I'll update the related issue on Create React App to update the documentation accordingly.

@amadeogallardo that configuration should work fine for all versions of VS Code.

Was this page helpful?
0 / 5 - 0 ratings