如何使用Resharper调试Jasmine测试? [英] How do you debug Jasmine tests with Resharper?

查看:103
本文介绍了如何使用Resharper调试Jasmine测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2012中使用Resharper运行Jasmine测试时,我无法找到调试(遍历)JavaScript代码的方法。我尝试使用浏览器(Chrome)运行测试但测试运行器在测试后立即关闭端口运行,因此我不能在代码中放置断点。还尝试在Internet Explorer中运行并在Visual Studio中放置断点,但它不会附加到进程。我的测试有很多///参考脚本,Resharper自动包含在测试运行器中,但我不想为每个我想要调试的测试手动执行此操作。请帮我理解这个。如果您的茉莉花测试失败,那么如何调试呢?

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).

当然,之后是一定要删除调试器关键字!也许在生产代码中通常没有非常简单的方法来避免它(如果你不仅在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测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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