当我使用 Electron 时,我无法在 VS Code 中调试我的 Jest 测试。我的测试应该使用 Electron,而不是 Node(由于使用了本机模块)。
{
"name": "Jest Unit Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"program": "${workspaceRoot}/node_modules/.bin/jest",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"env": {
"ELECTRON_RUN_AS_NODE": "1",
"NODE_ENV": "test",
"BABEL_DISABLE_CACHE": "1"
},
"args": [
"-i",
"--verbose",
"-c test/config/jest.unit.json"
],
"internalConsoleOptions": "openOnSessionStart"
},
它基于用于使用 Node 调试 Jest 的常用配置(工作正常),但我无法让它与 Electron 一起使用。Jest 命令是正确的,但是--debug-brk --inspect
VSCode 添加的选项似乎与 Jest 混淆了。