我使用Angular CLI生成角度项目。
我想调试e2e测试。 我为了做到这一点不知所措,我应该将测试从* .ts编译为* .js, 我发现了这个信息here,但它对我不起作用。
此外,我还阅读了this文章,但它也不适用于我。
我做错了什么?请帮帮我......我花了一个星期没有结果......
我的.vscode文件夹和 tasks.json 文件
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [
{
"taskName": "e2e-compile",
"isBuildCommand": true,
"args": [
"run",
"e2e-compile"
]
}
]
}
launch.json 文件
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch e2e Tests",
"type": "node",
"request": "launch",
"stopOnEntry": false,
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"args": [
"${workspaceRoot}/protractor.conf.debug.js"
],
"preLaunchTask": "e2e-compile",
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/out-tsc-e2e/*.js"
]
}
]
}
protractor.config.debug.js 文件
var SpecReporter = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./dist/out-tsc-e2e/**/*.e2e-spec.js'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
}
};
然后我添加了断点并使用F5进行调试,我等待暂停,但它只是失败了。 我将不胜感激任何帮助。
答案 0 :(得分:1)
我怀疑您的问题与量角器配置的第一行有关:var SpecReporter = require('jasmine-spec-reporter');
在执行任务期间查看控制台窗口输出:
Debugger listening on [::]:26978
[12:07:47] I/launcher - Running 1 instances of WebDriver
[12:07:47] I/direct - Using ChromeDriver directly...
[12:07:50] E/launcher - Error: TypeError: SpecReporter is not a constructor
at onPrepare (c:\src\TableDojo\ClientApp\protractor.conf.debug.js:25:34)
Jasmine发生了重大变化(见SpecReporter is not a constructor error when running protractor using angular-cli)。尝试使用var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
在我的机器上工作: - )