1

在 Angular RC1 之后,我不得不重新配置 Karma。现在所有测试都运行正常,唯一突出的问题是:我永远无法修复业力覆盖率以显示任何内容(始终显示 100%)我 99.99% 肯定是配置问题,但我错过了什么?

我的业力.conf

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

    basePath: '',

    frameworks: ['jasmine'],

    files: [
      // Polyfills.
      'node_modules/es6-shim/es6-shim.js',

      'node_modules/reflect-metadata/Reflect.js',

      // System.js for module loading
      'node_modules/systemjs/dist/system-polyfills.js',
      'node_modules/systemjs/dist/system.src.js',

      // Zone.js dependencies
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',

      // RxJs.
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
      // { pattern: 'node_modules/ng2-translate/**/*.js', included: false, watched: false},


      {pattern: 'karma-test-shim.js', included: true, watched: true},
      {pattern: 'dist/app/matchers.js', included: true, watched: true},

      // paths loaded via module imports
      // Angular itself
      // {pattern: 'node_modules/@angular/router-deprecated/index.js', included: false, watched: true},
      {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
      // {pattern: 'node_modules/@angular2-material/**/*.js', included: false, watched: true},
      {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},

      // Our built application code
      {pattern: 'dist/app/**/*.js', included: false, watched: false},

      // paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      {pattern: 'dist/**/*.html', included: false, watched: false},
      {pattern: 'dist/**/*.css', included: false, watched: false},

      {pattern: 'dist/assets/images/**/*.jpg', watched: false, included: false, served: true},
      {pattern: 'dist/assets/images/**/*.png', watched: false, included: false, served: true},
      {pattern: 'dist/assets/i18n/**/*.json', watched: false, included: false, served: true},
      // {pattern: 'dist/local_config.json', watched: false, included: false, served: true},
      {pattern: 'node_modules/ng2-translate/**/*.js',  watched: false, included: false, served: true},
      // paths to support debugging with source maps in dev tools
      {pattern: 'src/**/*.ts', included: false, watched: false},
      {pattern: 'dist/**/*.js.map', included: false, watched: false}
    ],

    // proxied base paths
    proxies: {
      // required for component assests fetched by Angular's compiler
      "/app/": "/base/dist/app/",
      "/assets/": "/base/dist/assets/",
      "/i18n/": "/base/dist/assets/i18n/",
      "//": "/base/dist/"
    },

    // list of files to exclude
    exclude: [
      'node_modules/@angular/**/*spec.js'
    ],

    // // preprocess matching files before serving them to the browser
    // // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'app/**/!(*spec).js': ['coverage']
    },

    meta: {
      'app/**/*.js': { format: 'register' }
    },

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

    coverageReporter: {
        dir: 'coverage/',
        reporters: [
            { type: 'text-summary' },
            { type: 'json', subdir: '.', file: 'coverage-final.json' },
            { type: 'html' }
        ],
        instrumenterOptions: {
            istanbul: { noCompact: true }
        }
    },

    // coverageReporter : {
    //   type: 'html',
    //   dir: 'coverage/'
    // },


    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}
4

0 回答 0