Car*_*pon 6 jestjs visual-studio-code stenciljs
我正在努力让 Visual Studio Code 调试器与 Jest 测试一起工作。
这是我的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是我的带有几个断点的 Jest 测试:
当我点击绿色播放按钮使用调试器运行测试时,断点永远不会被击中。
任何帮助,将不胜感激
我个人使用这个配置
{
"name": "Launch e2e test",
"type": "node",
"request": "launch",
"env": {
"NODE_ENV": "test"
},
"args": [
"--colors",
"--config=${workspaceFolder}/jest-e2e.config.js",
"--runInBand",
"--coverage"
],
"runtimeArgs": [
"--nolazy"
],
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
},
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart"
}
Run Code Online (Sandbox Code Playgroud)
通过您的配置文件更改 jest-e2e.config.js 。并移除或保留覆盖范围
就像 Laura Slocum 所说,你肯定会遇到行号问题。就我而言,我个人认为问题来自于玩笑配置,即转换:
transform: {
"^.+\\.(t|j)s$": "ts-jest"
},
Run Code Online (Sandbox Code Playgroud)
小智 3
这个配置让我可以调试 jest 测试。不幸的是,在组件中命中断点并不会显示正确的行,即使它正在单步执行正确的代码。我相信这可能是 VSCode 错误
{
"name": "Jest", // This is the configuration name you will see in debug sidebar
"type": "node",
"request": "launch",
"port": 5858,
"address": "localhost",
"stopOnEntry": false,
"runtimeExecutable": null,
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"preLaunchTask": "compile",
"runtimeArgs": [
"--inspect-brk", // node v8 use debug-brk if older version of node
"${workspaceRoot}/node_modules/.bin/jest",
"--watch",
"--bail",
"--runInBand"
],
"cwd": "${workspaceRoot}"
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4637 次 |
| 最近记录: |