jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.83k stars 290 forks source link

How do I debug a failing test without enabling stop on "all exceptions?" #463

Open ELLIOTTCABLE opened 5 years ago

ELLIOTTCABLE commented 5 years ago

Environment

  1. node -v: v10.12.0

  2. npm -v: 6.9.0

  3. npm ls jest: jest@23.5.0

  4. your vscode-jest settings if customized:

    • jest.pathToJest? blank
    • jest.pathToConfig? blank
  5. Operating system: macOS 10.14.5

Prerequisite

Relevant Debug Info

The only line in the Inspector console that appears to be jest-related:

spawning process with command=/Users/ec/Sync/Code/excmd/node_modules/.bin/jest, args=--json,--useStderr,--outputFile,/var/folders/xt/wm01x2h50nv993t_csb1t5qm0000gn/T/jest_runner.json,--watch,--no-color

(Unrelatedly: Every other output appears to be self-annotated by the relevant plugin with its' plugin-name; maybe add [jest] … to your log-lines?)

Here's my launch.json configuration:

{
   "type": "node",
   "name": "vscode-jest-tests",
   "request": "launch",
   "args": ["--runInBand"],
   "cwd": "${workspaceFolder}",
   "console": "integratedTerminal",
   "internalConsoleOptions": "neverOpen",
   "program": "${workspaceFolder}/node_modules/jest/bin/jest.js"
}

Expected Behavior

Clicking the ‘debug’ annotation on a broken test would launch a debugger, which then would stop executing at that test, or possibly on the exception generated during that test, even with “all exceptions”

Actual Behavior

I must be missing something, because without enabling stopping on caught exceptions, I just see the tests running in the debugger output, and then the process exits … and if I do turn on stop on caught exceptions (“all exceptions” in VScode), which can't be necessary (!?), then the debugger stops on a billion low-level Node control-flow constructs involving module-loading within Jest itself.

Screen Shot 2019-06-14 at 10 01 29

I'm assuming this is user-error, but I can't figure out what I've configured incorrectly. How do I simply debug one failing test?

connectdotz commented 5 years ago

did you set a breakpoint and the debugger just didn't stop?