How do you debug Jasmine tests with Resharper?(你如何使用 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 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:你如何使用 Resharper 调试 Jasmine 测试?
基础教程推荐
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 动态更新多个选择框 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06