FutuToad
FutuToad

Reputation: 2850

Webstorm Karma test debugging - breakpoint not hit

I have installed the chrome jet brains extension

I have tests like this:

describe('Service tests', function () {


 beforeEach(module('app'));

    it('should have a Service', inject(function($injector) {
        var exist = $injector.has('dataService');

etc

but no luck getting breakpoints to hit any where in the tests. I can get the debugger to break when writing debugger, but an unable to step through.

Upvotes: 7

Views: 4941

Answers (3)

Ε Г И І И О
Ε Г И І И О

Reputation: 12371

If by any chance you are using Angular and you have removed all the coverage related stuff from your karma.config file and are still unable to hit the breakpoints, look into the angular.json. It might be having the codeCoverage bit set to true.

"test": {
  ...
  "options": {
    ...
    "codeCoverage": false,
    ...
  }
  ...
}

Upvotes: 0

Anna Tolochko
Anna Tolochko

Reputation: 1855

If you are building with Webpack you might need to specify the devtools option in your webpack config property in karma.conf.js like this:

module.exports = (config) => {
    config.set({
         webpack: {
             ...,
             devtool: 'inline-source-map'
         }
    })
};

This solution works for me with Webpack v3.

Upvotes: 2

lena
lena

Reputation: 93848

Do you have karma-coverage set up in your karma config? It uses instrumented code, so debugging is not possible. Related tickets: http://github.com/karma-runner/karma/issues/630, http://youtrack.jetbrains.com/issue/WEB-8443

Upvotes: 9

Related Questions