firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
265 stars 124 forks source link

Use skipFiles when debugging tests #234

Closed Zikoat closed 2 years ago

Zikoat commented 2 years ago

Hi, i guess this is a feature request. Is it possible to skip node_modules when debugging tests using jest? There are a lot of stack frames, and most of the time we are investigating issues in our own code, and not in other people's libraries.

Reproduction steps:

  1. git clone https://github.com/Zikoat/vscode-jest-skipfiles-repro.git
  2. cd .\vscode-jest-skipfiles-repro\
  3. npm install
  4. code .
  5. Go to sum.js and add a breakpoint on line 2
  6. go to debug tab and press "Run unit tests"

Debugger stops on that line and shows the stack frames as skipped. This is because of the "skipFiles" setting in launch.json. image

  1. Go to sum.unit.js and press "debug"

The debugger now stops on the specified line, but there are a lot of stack frames that are shown. image

Expected behavior: Stack frames are not shown when a test is being debugged. We can also set this for js debug sessions that vscode auto-attaches by setting this setting, but that is not used in this project. Maybe this setting should be taken into account, or there could be some command line options we could set to add to skipFiles?

Zikoat commented 2 years ago

Ah, found it now, from here: https://jakeginnivan.medium.com/vscode-jest-setup-d50dc0062ab9 Add to settings.json:

{
  "jestrunner.debugOptions": {
    "skipFiles": ["${workspaceFolder}/node_modules/**/*.js","<node_internals>/**"],
    "smartStep": true
  },
}

Instead of debug.javascript.terminalOptions.