使用VSCode調試Jest

0. 環境

Node版本:8.12.0
操做系統:windows10javascript

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調試

執行代碼java

npm run debugger

4. 打斷點調試

經過鼠標,或者經過Ctrl+Shift+D進入VSCode的調試面板。
點擊調試便可。node

相關文章
相關標籤/搜索