This Question is Answered

2 "helpful" answers available (2 pts)
2 Replies Last post: Jun 5, 2014 7:29 PM by Stefan H.  
Stefan H. Newbie 2 posts since
Jun 5, 2014
Currently Being Moderated

Jun 5, 2014 10:45 AM

Debugging unit tests with Karma in WS8?

Hello,

 

it is the first time I try to debug JS unit tests, so please bear with me. I set up Karma in WS8 and ran my QUnit tests nicely. But when I tried to debug them, I was required to install a browser plugin. This kind of worked, but has some drawbacks:

  1. I cannot see the "test tree" and I have no idea how to re-run a single test case. This makes debugging hard, since I need to configure "clever" conditional breakpoints.
  2. Every time I debug, a browser tab gets opened, which means WS loses focus (which is a bit annoying)
  3. I am actually using TypeScript in part, but I have to set the breakpoints in the .js files (not so bad, since the compiled JS is readable)

 

So I was wondering if there is a better way to run and debug tests. Maybe there is an alternative to Karma, with better IDE integration?

 

Advice is greatly apprechiated.

 

Regards,

Stefan

Elena Pogorelova Apprentice 892 posts since
Oct 5, 2011
Currently Being Moderated
Jun 5, 2014 5:23 PM in response to: Stefan H.
Re: Debugging unit tests with Karma in WS8?

1. no test tree: known limitation (specific to karma). We haven't yet managed to find a workaround for it, still investigating

   rerun single test: there is no way to pass a spec file (or individual test/suite) to karma directly - see https://github.com/karma-runner/karma/issues/553.

   You can have several karma configuration files with different sets of  tests included. Plus you can rename individual tests/suits in the way  mentioned in https://github.com/karma-runner/karma/issues/553

 

3. You need using source maps to enable typescript debugging. See http://stackoverflow.com/questions/23133927/sourcemap-support-in-webstorm-for-unit-test for more information. Note that https://github.com/karma-runner/karma/issues/990 is fixed, so it's currently possible to use karma-typescript-preprocessor. I'm attaching a sample project that shows how it can be used

Attachments:

More Like This

  • Retrieving data ...