[英]How do I debug my JavaScript that is being executed by Chutzpah/PhantomJS
I am using Chutzpah to execute my JavaScript unit tests. 我正在使用Chutzpah来执行我的JavaScript单元测试。
I reference paths to my source files and below have a series of tests. 我引用了我的源文件的路径,下面有一系列的测试。 Text Explorer in Visual Studio lists my tests and I can execute them directly from the IDE, so everything seems to be working correctly.
Visual Studio中的Text Explorer列出了我的测试,我可以直接从IDE执行它们,所以一切似乎都正常工作。
However I would like to step into the source code that is being executed when my tests are run. 但是,我想进入运行测试时正在执行的源代码。
Is this possible? 这可能吗?
Update: Version 4.1.0 of Chutzpah adds integrated VS debugging . 更新: Chutzpah 4.1.0版添加了集成的VS调试 。
This is not currently possible using Chutzpah. 使用Chutzpah目前无法实现这一目标。 The best you can do is to install the context menu extension which will add a "Open In Browser" right click option.
您可以做的最好的事情是安装上下文菜单扩展 ,这将添加“在浏览器中打开”右键单击选项。 Then you can use the browser's built in debugging tool to step through the code.
然后,您可以使用浏览器的内置调试工具来逐步执行代码。
I would love to add an integrated way to plug into the VS debugging system but have not figured out how to do that yet. 我想添加一个集成的方式来插入VS调试系统,但还没有弄清楚如何做到这一点。
Maybe this could point you in the right direction: 也许这可以指出你正确的方向:
I made a quick and dirty screenshot grabber for CasperJS using captureBase64('png') 我使用captureBase64('png')为CasperJS做了一个快速而又脏的截图抓取器
It is POSTing the image into the receiving server which then sends it via socket.io to the browser which displays it is as inline image. 它将图像POST到接收服务器,然后通过socket.io将其发送到浏览器,显示它作为内嵌图像。
The source code is available on github: 源代码可以在github上找到:
https://github.com/maciejjankowski/flaming-octo-puss https://github.com/maciejjankowski/flaming-octo-puss
I'm not sure how compatible it is with PhantomJS, but CasperJS works flawlessly so if chutzpah is using PhantomJS there is a chance you could make this concept to work. 我不确定它与PhantomJS的兼容性如何,但CasperJS可以完美运行,所以如果chutzpah使用PhantomJS,你有可能让这个概念起作用。
You would need to add this to each step or set it as onStepComplete
handler: 您需要将其添加到每个步骤或将其设置为
onStepComplete
处理程序:
this.evaluate( function(img){
__utils__.sendAJAX("http://localhost:8001/", 'POST', {'img' : img }, false);
},
{'img' : this.captureBase64('png')}
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.