量角器打字稿VScode调试

时间:2019-04-07 09:55:43

标签: typescript visual-studio-code protractor

我正在尝试使用Typescript量角器,并且正在努力使用VScode调试测试。

测试开始时浏览器打开,调试器在调试点停止(获取url并单击两次并发送sendkeys语句之后),但是浏览器为空(未打开指定的URL,并且浏览器中未执行针对其执行的代码的操作) !)。当我恢复测试执行时,测试中的所有步骤都会发生!

Launch.json

{
"version": "0.2.0",
"configurations": [

    {
        "type": "node",
        "request": "launch",
        "name": "Working thru node",
        "program": "${workspaceFolder}/node_modules/.bin/protractor",
        "args": [
            "protractor.conf.js"
        ],
        "protocol": "inspector",
        "runtimeArgs": ["--nolazy"],
        "sourceMaps": true,
        "console": "internalConsole",
        "outputCapture": "std"
    }
]}

tsconfig.json

{
    "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "declaration": false,
    "outDir": "output",
    "strict": true,
    "noImplicitAny": false,
    "moduleResolution": "node",
    "types": ["jasmine", "node"],
    "esModuleInterop": true,
    "inlineSourceMap": true,
   },
  "exclude": ["node_modules/*"]
}

Config.ts

import {Config} from 'protractor';
export let config: Config = {

   framework: "jasmine",
   capabilities: {
       browserName: "chrome"
   },
   specs: ["specs/*.js"],
   seleniumAddress: "http://localhost:4444/wd/hub"
};

SampleTest.ts

enter code here
import { browser, element, by, protractor, $ } from "protractor";

describe("Super Calculator", function(){

   beforeEach(function(){
       browser.get("https://juliemr.github.io/protractor-demo/");
   })

   it("Should be able to add two positive numbers", function(){
       element(by.model("first")).sendKeys(1);
       element(by.model("second")).sendKeys(1);
       element(by.id("gobutton")).click();
       var Ec = protractor.ExpectedConditions;
       browser.wait(Ec.not(Ec.presenceOf($(".ng-valid-parse"))));
       expect<any>(element(by.binding('latest')).getText()).toEqual('2');
   })
}) 

使用

运行测试
 npm run tsc && protractor output/config.js  

我的调试点位于测试的最后一行,执行在调试点处停止,但该语句上方指定的操作未在浏览器中发生。当我恢复测试时,测试就通过了!我期望看到浏览器的url打开并发送sendkeys,并且在调试点停止执行时发生单击!谁能帮助我了解问题所在。

1 个答案:

答案 0 :(得分:-1)

我最近在 VSCode 中新手学习量角器,也遇到了这个问题。这可能与异步有关。我建议在 chrome 检查器中调试, http://www.protractortest.org/#/debugging#disabled-control-flow。无论如何,在量角器中调试并不像在其他语言中那么容易。