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的調試面板。
點擊調試即可。