简体   繁体   English

如何调试Chutzpah / PhantomJS正在执行的JavaScript

[英]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.

相关问题 如何使用Chutzpah更改基础的Phantomjs对象设置? - How do I change the underlying Phantomjs object settings using Chutzpah? 我如何调试PhantomJS Javascript测试? - How Can I Debug PhantomJS Javascript Tests? 如何调试在 android 移动团队应用程序的 microsoft 团队选项卡中执行的 javascript 代码? - How can I debug javascript code that is being executed inside microsoft teams tab of android mobile teams application? 如何从Chutzpah在PhantomJS中设置视口大小 - How to set viewport size in PhantomJS from Chutzpah 如何在我的网站上调试Facebook JavaScript api错误? - How do I debug Facebook JavaScript api errors on my site? 如何使用Firebug或任何其他方式“立即”查找/分析正在执行的JavaScript? - How do I find/profile what JavaScript is being executed “right now” using Firebug or any other way? 我的Safari浏览器未执行我的JavaScript - My javascript is not being executed in my safari browser 如何捕获PhantomJS提取的页面中生成的JavaScript错误? - How do I capture JavaScript errors generated in a page fetched by PhantomJS? 有没有办法在chutzpah中执行phantomJS语句? - is there a way to execute phantomJS statements in chutzpah? 如何在JavaScript中调试客户端错误? - How do I debug client errors in JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM