如何在 VS CODE 中调试量角器? [英] How to debug protractor in VS CODE?

查看:62
本文介绍了如何在 VS CODE 中调试量角器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试量角器测试脚本,但我无法找到理解如何调试的好资源,有人可以建议我推荐几个最好的网站,以及我们可以调试多少种方法来调试量角器测试脚本.

I'm trying to debug protractor test script but I'm not able to find good source to understand how to debug, can any one suggest me few best sites to refer and how many ways can we debug the protractor test script.

推荐答案

你有 2 个最好的方法.

you have 2 best ways.

方法 A:

1) 配置 VSCode.

1) Configure VSCode.

这是我的启动配置:(根据需要更改文件夹路径和文件).

This is my launch configuration: (change the folder path and files as needed).

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Backoffice",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
            "stopOnEntry": false,
            "args": ["${workspaceRoot}/e2e/backoffice/protractor_backoffice.js"],
            "sourceMaps": true,
            "outFiles": [ "${workspaceRoot}/e2e/backoffice/**/*.js" ],
            "smartStep": true
        }
    ]
}

2) 完成此操作后,您就可以运行调试器,它应该可以工作了.

2) Once you have done this you just can run the debugger and it should work.

信息:要添加断点,只需在您的代码调试器"中写入;(不带引号).

INFO: To add breakpoints just write in your code "debugger;" (without quotes).

非常重要!!!!要将代码与浏览器同步,您可以使用异步函数和等待方法.

VERY IMPORTANT!!!! To syncronize your code with your browser you have use async functions and await methods.

async/await 和断点示例:

example of async/await and breakpoint:

async myFunction() {
 debugger;
 await this.myElement.click();
}

方法 B:

在 VSCode 中打开一个终端并写入:

Open a terminal in VSCode and write:

node --inspect-brk path/to/protractor/bin/protactorpath/to/protractorconfig.js

node --inspect-brk path/to/protractor/bin/protactor path/to/protractorconfig.js

示例:

节点 --inspect-brk .\node_modules\protractor\bin\protractor.\e2e\backoffice\protractor_backoffice.js

node --inspect-brk .\node_modules\protractor\bin\protractor .\e2e\backoffice\protractor_backoffice.js

它会打开开发者 chrome 工具,其中与 VSCode 调试器非常相似,但它提供了更多信息.

It opens dev chrome tools, in there is pretty much as VSCode debugger, but it gives a bit more information.

祝你好运!

这篇关于如何在 VS CODE 中调试量角器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆