angular-karma_test-explorer icon indicating copy to clipboard operation
angular-karma_test-explorer copied to clipboard

Unable to debug typescript angularjs tests

Open BenjaminThomson opened this issue 7 years ago • 4 comments

Describe the bug Because I'm testing angularjs (i.e 1.x) I'm running in 'Karma' mode and all of my tests are found and run without any issues. However, I'm running in TypeScript using the karma typescript pre-processor etc and none of my break points are being hit (they remain as an empty circle and don't go red).

To Reproduce Here is a copy of my karma.conf.js file:

module.exports = function (config) {
  config.set({

    basePath: '',

    frameworks: ['jasmine', 'karma-typescript'],

    preprocessors: {
      '**/*.ts': ['karma-typescript'],
      '**/*.html': ['ng-html2js']
    },

    ngHtml2JsPreprocessor: {
      moduleName: "templates",
    },

    typescriptPreprocessor: {
      options: {
        sourceMap: true, // generate source maps
        noResolve: false // enforce type resolution
      },
      transformPath: function (path) {
        return path.replace(/\.ts$/, '.js');
      }
    },

    // list of files / patterns to load in the browser
       files: [
      "./app/env.ts",
      "./assets/lib/angular/angular.js",
      "./assets/lib/angular/angular-sanitize.js",
      "./assets/lib/angular/angular-ui-router.js",
      "./assets/lib/angular-animate/angular-animate.js",
      "./assets/lib/angular-translate/angular-translate.js",
      "./assets/lib/angular-translate/angular-translate-loader-url.js",
      "./assets/lib/angular-cookie/angular-cookie.js",
      "./assets/lib/angular-mocks/angular-mocks.js",
      "./assets/lib/lodash/core.js",
      "./app/controllers/**/*.ts",
      "./app/routing/**/*.ts",
      "./app/services/**/*.ts",
      "./app/shared/**/*.ts",
      "./app/**/*.html",
      "./spec/mocks/**/*.ts",
      "./spec/**/*spec.ts",
      "./app/app.ts",
    ],

    // list of files to exclude
    exclude: [],

    reporters: ["karma-typescript", "dots"],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['ChromeDebugging'],

    customLaunchers: {
      ChromeDebugging: {
        base: 'Chrome',
        flags: ['--remote-debugging-port=9333']
      }
    },
    singleRun: false,
    concurrency: Infinity
})}

Logs There are no errors in the log.

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Angular Version: AngularJS v1.6.6
  • Node version: 6.9.0
  • karma.conf.js path from the root folder you re opening in vscode (root path and this is set correctly).

BenjaminThomson avatar Sep 26 '19 23:09 BenjaminThomson

Hi @slagbat I am sorry but Angular.Js is not supported, if you can upload a test project for me I will make the best to replicate it but unfortunately I do not use Angular.js anymore to make a proper representation myself. I am merging right now a fix from a user related to the source maps in the debugger so please make sure to try the new version to check if that solves the issue.

Raagh avatar Sep 29 '19 08:09 Raagh

Hi @slagbat I am sorry but Angular.Js is not supported, if you can upload a test project for me I will make the best to replicate it but unfortunately I do not use Angular.js anymore to make a proper representation myself. I am merging right now a fix from a user related to the source maps in the debugger so please make sure to try the new version to check if that solves the issue.

I'll see if I can upload something later for you. I've got the tests running and displaying in the test explorer it's just the debugging part and if I can't get that to work then it's not the end of the world as the plan is to migrate to Angular in the near future.

BenjaminThomson avatar Sep 29 '19 22:09 BenjaminThomson

Great thank you very much I will make sure to take a look at it once you upload it. did the new version solved the debugging issue for you?

Raagh avatar Oct 01 '19 13:10 Raagh

Unfortunately it didn't solve the debugging issue. I was going to upload the project but then found that on my laptop it wasn't showing the tests but on my desktop it does so I want to get to the bottom of that first. It must be a config thing (maybe not having ts-node on my laptop or something like that).

BenjaminThomson avatar Oct 03 '19 07:10 BenjaminThomson