0. 环境

Node版本:8.12.0
操作系统:windows10

1. 配置launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Jest Tests",
            "type": "node",
            "request": "launch",
            "runtimeArgs": [
                "--inspect-brk",
                "${workspaceRoot}/node_modules/.bin/jest",
                "--runInBand"
            ],
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen",
            "port": "9229"
        }
    ]
}

2. package.json里添加代码

"scripts": {
    "debugger": "node --inspect-brk ./node_modules/jest/bin/jest --runInBand --no-cache --no-watchman"
}

3. 启动Jest调试

执行代码

npm run debugger

4. 打断点调试

通过鼠标,或者通过Ctrl+Shift+D进入VSCode的调试面板。
点击调试即可。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2021-07-13
  • 2021-09-19
  • 2021-09-22
  • 2022-01-05
  • 2022-12-23
猜你喜欢
  • 2021-08-27
  • 2021-09-18
  • 2020-03-15
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案