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

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

问题描述

在 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 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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