rel*_*one 5 debugging karma-coverage visual-studio-code angular
我目前遇到问题。我开始为我的 Angular 应用程序编写测试并想要调试它们。现在我已经用谷歌搜索了很多,我尝试了来自微软的食谱(https://github.com/Microsoft/vscode-recipes/tree/master/Angular-CLI),而我最接近使它工作的是这个BlogPost
http://blog.mlewandowski.com/Debugging-Karma-tests-with-VSCode.html
现在至少我可以将调试器附加到 VS-Code。然而,VS Code 仍然不会在断点处停止,而是测试继续运行。VS Code 中的断点也将保持未经验证的状态(见图)
这就是我到目前为止所拥有的(我只提供我更改过的部分,以免发布太多代码)。
知道我做错了什么吗?除此之外,调试工作正常。我可以调试我的 Node.js 应用程序,并且调试 ng 服务也可以正常工作。
启动.json
{
"type": "chrome",
"request": "attach",
"name": "MyApp - Tests",
"address": "localhost",
"port": 9222,
"pathMapping": {
"/": "${workspaceRoot}",
"/base/": "${workspaceRoot}"
}
}
Run Code Online (Sandbox Code Playgroud)
karma.conf.js
browsers: [
'ChromeDebugging'
],
customLaunchers: {
ChromeDebugging: {
base: 'Chrome',
flags: ['--remote-debugging-port=9222']
}
}
Run Code Online (Sandbox Code Playgroud)
您是否安装了“Chrome 调试器”扩展程序。
看看这个指南。 https://github.com/Microsoft/vscode-recipes/tree/master/Angular-CLI
更新:这是我的 launch.json 也许你可以尝试一下。
{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceFolder}"
},
{
"name": "ng e2e",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceFolder}/e2e/protractor.conf.js"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
因果报应会议
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5719 次 |
| 最近记录: |