簡體   English   中英

業力-如何指向源地圖進行打字稿覆蓋

[英]Karma - How to point to a source map for typescript coverage

我想使用業力覆蓋為我的打字稿源文件生成一份覆蓋率報告。 我的單元測試是用javascript編寫的,並且我使用的是Jasmine Test框架。

我的文件夾結構如下所示:

node_modules/
app/
  app.js
  app.js.map
  app.ts
  components/
  controllers/
      SampleController.ts
  directives/
  filters/
  services/

unittests/
  karma.conf.js
  components/
  controllers/
      SampleControllerTest.js
  directives/
  filters/
  services/

我的karma.conf.js

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    plugins: [
          'karma-jasmine',
          'karma-ng-html2js-preprocessor',
          'karma-coverage',
          'karma-phantomjs-launcher',
          'karma-sourcemap-loader'

      ],
    preprocessors: {
        '../app/directives/controls/**/*Template.html' : [ 'ng-html2js' ],

            // source files, that you wanna generate coverage for
            // do not include tests or libraries
            // (these files will be instrumented by Istanbul)
        '../app/app.js' : ['sourcemap', 'coverage' ],

    },
    reporters: ['progress', 'coverage'],

    // web server port
    port: 9876,

    coverageReporter: {
          type : 'html',
          dir : 'coverage/'
      },
    // and some other stuff
  });
};

目前,我的覆蓋率報告提供了足夠的指標,但與單個打字稿文件無關,但與app.js無關。

我想我要么弄亂了預處理程序配置,要么需要指定源映射。

安妮提示?

使用karma-istanbul-remap對我有用。

karma.conf.js:

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    plugins: [
          'karma-jasmine',
          'karma-ng-html2js-preprocessor',
          'karma-coverage',
          'karma-phantomjs-launcher',
          'karma-remap-istanbul'

      ],
    preprocessors: {
        '../app/directives/controls/**/*Template.html' : [ 'ng-html2js' ],

            // source files, that you wanna generate coverage for
            // do not include tests or libraries
            // (these files will be instrumented by Istanbul)
        '../app/app.js' : ['coverage' ],

    },
    reporters: ['progress', 'coverage', 'karma-remap-istanbul'],

    // web server port
    port: 9876,

    coverageReporter: {
        type : 'json',
        subdir : '.',
        dir : 'coverage/',
        file : 'coverage.json'
    },
    remapIstanbulReporter: {
          src: 'coverage/coverage.json',
          reports: {
              lcovonly: 'coverage/lcov.info',
              html: 'coverage/html/report'
          },
          timeoutNotCreated: 5000, // default value
          timeoutNoMoreFiles: 1000 // default value
    },
    // and some other stuff
  });
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM