How do you debug Jasmine tests with Resharper?

纵饮孤独 提交于 2019-11-29 20:57:14
zbynour

Try to use debugger keyword. Simply add the following line to the code you want to debug (perhaps into the spec):

debugger;

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

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.

Since I didn't got debugger; to work I found another solution. By adding the following to my test, resharper won't be notified that the test has finished so we can set debug breakpoints in the opened browser (I use chrome) and update (F5) the page.

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

Since Jasmine 2.0 you need to use:

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

Stop the tests in resharper testrunner window when you're done.

Also this can be done for QUnit

QUnit.moduleDone = function(){}
Jason Bowers

As I posted on Debugging jasmine tests with resharper and phantom js

I got debugger; to work by setting IE 11 as my test browser in ReSharper options. 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. You really do not need to interact with the browser.

I know this is an old question and this answer is slightly off topic but if you don't want to interfere with the callback Chutzpah test runner context menu could support you here. Run the tests in resharper/phantomjs (so you don't get tab explosion) and debug in Chrome (or the your preferred browser) fired off a right click:

Chutzpah Test Runner Context Menu Extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!