简体   繁体   English

使用resharper和phantom js调试jasmine测试

[英]Debugging jasmine tests with resharper and phantom js

Similar question was already asked some time ago How do you debug Jasmine tests with Resharper? 前一段时间已经问过类似的问题你如何使用Resharper调试Jasmine测试? What is suggested there doesn't really work for me (place debugger; in test code). 建议有什么不适合我(放置debugger;在测试代​​码中)。 Each time the tests are run, a new browser window opens and thread jumps through debugger. 每次运行测试时,都会打开一个新的浏览器窗口,并且线程会跳过调试器。 Is there any way to make it work? 有没有办法使它工作? And also is there any way to debug jasmine tests with phantom runner and Resharper? 还有没有办法用幻影跑步者和Resharper调试茉莉花测试?

Thanks in advance 提前致谢

To debug in the browser, add the code below to your js test file. 要在浏览器中进行调试,请将以下代码添加到js测试文件中。

jasmine.getEnv().currentRunner_.finishCallback = function () {};

Resharper won't be notified that the test has finished so we can set debug breakpoints in the opened browser (I use chrome) and F5 the page. Resharper将不会通知测试已完成,因此我们可以在打开的浏览器(我使用chrome)和F5页面中设置调试断点。

Stop the tests in resharper testrunner window when you're done. 完成后,在resharper testrunner窗口中停止测试。

Edit: 编辑:
Since Jasmine 2.0 you need to use: 从Jasmine 2.0开始,您需要使用:

ReSharperReporter.prototype.jasmineDone = function () { };

Jason's answer was really helpful. 杰森的回答非常有帮助。 But I'd like to add that you have to enable script debugging in IE: Internet Options -> Advanced -> uncheck 'Disable script debugging (Internedt Explorer)'. 但我想补充一点,你必须在IE中启用脚本调试:Internet选项 - >高级 - >取消选中'禁用脚本调试(Internedt Explorer)'。
Then you can put debugger in your js and it will raise the 'Visual Studio Just-In-Time Debugger' popup. 然后你可以把调试器放在你的js中,它会引发'Visual Studio Just-In-Time Debugger'弹出窗口。

I got debugger; 我得到了调试器; to work by setting IE 11 as my test browser in ReSharper options. 通过在ReSharper选项中将IE 11设置为我的测试浏览器来工作。 The cool thing is that you can set your breakpoints in the Visual Studio version of the code and set through and debug using Visual Studio. 很酷的是,您可以在Visual Studio版本的代码中设置断点,并使用Visual Studio进行设置和调试。 You really do not need to interact with the browser. 您真的不需要与浏览器进行交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM