Tho*_*der 11 debugging karma-runner visual-studio-code
我希望能够在Visual Studio Code中调试单元测试,但到目前为止它已经是一个混合包.
我的设置:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug tests",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
karma.config.js
customLaunchers: {
Chrome_with_debugging: {
base: 'Chrome',
flags: ['--remote-debugging-port=9222']
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎在某种程度上起作用,如果我启动VS Code调试器它似乎附加(底栏变为橙色).如果我做出改变,Karma也会启动和调试器 - 但它总是暂停zone.js
(顺便说一下这是一个Angular项目)而不会干扰我:
如果我点击"继续"它实际上击中了我的断点
我可以检查一些变量,但不是全部,
例如,我看不到actual
传递给Jasmine expect
方法的值.
所以a)为什么调试器总是在内部暂停zone.js
- 测试的代码来自Redux reducer并在任何Angular上下文之外调用,以及b)我无法检查局部变量(这是一个showstopper)马上)?
Bac*_*chu 12
在karma.conf.js中,我在您的版本中更新了添加的调试选项.
customLaunchers: {
Chrome_with_debugging: {
base: 'Chrome',
flags: ['--remote-debugging-port=9222'],
debug: true
}}
Run Code Online (Sandbox Code Playgroud)
launch.json 将以下代码段添加为启动配置,
{
"name": "Debug tests",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
Run Code Online (Sandbox Code Playgroud)
然后使用以下命令触发测试,
ng test --browsers Chrome_with_debugging
使用Visual Studio代码调试选项"调试测试"来附加到UT.有了这个,我能够使用"Visual Studio Code + Debugger for Chrome extension"中的断点调试单元测试.
问候
Basanth
归档时间: |
|
查看次数: |
9005 次 |
最近记录: |