在 Visual Studio 2012 中使用 Resharper 运行 Jasmine 测试时,我找不到调试(遍历)JavaScript 代码的方法.我尝试使用浏览器 (Chrome) 运行测试,但测试运行器在测试后立即关闭端口已运行,因此我无法在代码中放置断点.还尝试在 Internet Explorer 中运行并在 Visual Studio 中放置断点,但它不会附加到进程.我的测试有很多///reference 脚本,Resharper 自动包含在测试运行程序中,但我不想为我要调试的每个测试手动执行此操作.请帮助我理解这一点.如果你有一个 jasmine 测试失败,那么你如何调试它?
I can't find a way to debug (walk through) JavaScript code when running Jasmine tests with Resharper in Visual Studio 2012. I tried running tests with browser (Chrome) but the test runner closes the port as soon as the test is run and so I cannot put a breakpoint in the code. Also tried running in Internet Explorer and put breakpoints in Visual Studio but it won't attach to the process. My test has a lot of ///reference scripts that Resharper includes automatically in the test runner but I don't want to manually do this for every test that I want to debug. Please help me understand this. If you have a jasmine test that is failing, then how do you debug it?
尝试使用 debugger 关键字.只需将以下行添加到您要调试的代码中(可能添加到规范中):
Try to use debugger keyword. Simply add the following line to the code you want to debug (perhaps into the spec):
debugger;
它调用任何可用的调试功能.它不能在 IE 中运行,但在 Chrome 中运行良好(你写了你使用它,所以我想它仅用于调试就足够了).
It invokes any available debugging functionality. It doesn't work in IE but works pretty well in Chrome (you wrote you use it so I guess it's enough just for debugging).
当然,在那之后一定要删除 debugger 关键字!也许没有真正简单的方法可以在一般的生产代码中避免它(如果您不仅会在 spesc 中使用它)但是如果您对此 SO 问题可能会有所帮助.
Of course, after that be sure to remove the debugger keyword! Perhaps there is no really simple way how to avoid it in production code in general (in case you will use it not only in spesc) but if you are interested in this SO question could be helpful.
这篇关于你如何使用 Resharper 调试 Jasmine 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 javascript 认为文档“准备好"之前,如何让How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 认为文档“准备好
jasmine 运行和等待实际上是做什么的?What do jasmine runs and waitsFor actually do?(jasmine 运行和等待实际上是做什么的?)
如何提供模拟文件来更改 <input type='filHow to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模拟文件来更改 lt;input type=filegt; 的事
如何使用 Jasmine 对链式方法进行单元测试How to unit test a chained method using Jasmine(如何使用 Jasmine 对链式方法进行单元测试)
如何将 $rootScope 注入 AngularJS 单元测试?How do I inject $rootScope into an AngularJS unit test?(如何将 $rootScope 注入 AngularJS 单元测试?)
Jasmine - 如何监视函数中的函数调用?Jasmine - How to spy on a function call within a function?(Jasmine - 如何监视函数中的函数调用?)