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

2 comments

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



Attachment(s):
karma_ts.zip
0

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

0

Please sign in to leave a comment.