2017-04-16 87 views
1

我使用Angular CLI生成了角度项目。如何使用VS代码和类型脚本来调试e2e测试

我想调试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调试,我在等待暂停,但它只是失败。 我将不胜感激任何帮助。

回答

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) 

一直有突破茉莉花的变化(见SpecReporter is not a constructor error when running protractor using angular-cli)。试着用var SpecReporter = require('jasmine-spec-reporter').SpecReporter;

作品来改变上述行我的机器上:-)

+0

感谢您的帮助,但我已经切换到反应)) – nightmare