"configurations": [ { "name": "Jest Debug AllFile", "type": "node", "request": "launch", "protocol": "inspector", "program": "${workspaceRoot}/node_modules/jest/bin/jest", "stopOnEntry": false, "args": ["--runInBand", "--env=jsdom"], "runtimeArgs": [ "--inspect-brk" ], "cwd": "${workspaceRoot}", "sourceMaps": true, "console": "integratedTerminal" }, { "name": "Jest Debug File", "type": "node", "request": "launch", "protocol": "inspector", "program": "${workspaceRoot}/node_modules/jest/bin/jest", "stopOnEntry": false, "args": ["--runInBand", "--env=jsdom", "${fileBasename}"], "runtimeArgs": [ "--inspect-brk" ], "cwd": "${workspaceRoot}", "sourceMaps": true, "console": "integratedTerminal" }, ]
打開 vscode 的斷點調試工具node
對單文件調試
在對應的測試文件下,執行 Jest Debug Filejson
對全部文件調試
在任意位置執行,執行 Jest Debug AllFile
dom
斷點調試
在調試控制檯,能夠查看測試代碼,以及提示
在VS Code中調試Jest單元測試工具