Debugging unit tests with Karma in WS8?


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.


Comment actions Permalink

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

3. You need using source maps to enable typescript debugging. See for more information. Note that 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

Comment actions Permalink

Wow, thanks for the example project, and the clarifications. Very helpful.


Please sign in to leave a comment.