9

Similar question was already asked some time ago How do you debug Jasmine tests with Resharper? What is suggested there doesn't really work for me (place debugger; in test code). 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?

Thanks in advance

Community
  • 1
  • 1
Voice
  • 1,547
  • 16
  • 31
  • Did you try my [alternative solution](http://stackoverflow.com/a/17087589/498197) where you do the debugging in the browser. Don't know how to debug with phantom though. – Torbjörn Nomell Sep 05 '13 at 13:34
  • Hi, Torbjörn, yes that really works! You can add this comment as an answer, so I can mark it) – Voice Sep 06 '13 at 09:07

3 Answers3

12

To debug in the browser, add the code below to your js test file.

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.

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

Edit:
Since Jasmine 2.0 you need to use:

ReSharperReporter.prototype.jasmineDone = function () { };
Torbjörn Nomell
  • 3,020
  • 2
  • 24
  • 20
  • 1
    This is cool, but the answer is for chrome and not for PhantomJS – zumalifeguard Nov 02 '15 at 20:19
  • Also, if the tests are in TypeScript files, you'll get an error on access the `ReSharperReporter` global variable. One work around is to use syntax like this: `window['ReSharperReporter'].prototype.jasmineDone = function () { };` – zumalifeguard Nov 02 '15 at 20:37
  • many thanks, I wish had found this months ago when I spend days figuring out how to work around it. – Ibrahim ben Salah Dec 18 '16 at 18:44
1

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)'.
Then you can put debugger in your js and it will raise the 'Visual Studio Just-In-Time Debugger' popup.

0

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.

Jason Bowers
  • 496
  • 6
  • 12