2017-02-21 6 views
0

Мой отчет охват включает в себя импорт, как:Исключить файлы импорта, как angular.js, угловые-UI-router.js, угловой mocks.js и т.д. из базы Karma отчеты

node_modules\angular-mocks\    | 26.09 | 11.58 |  19.7 | 27.23 |    | 
    angular-mocks.js      | 26.09 | 11.58 |  19.7 | 27.23 |... 6,3107,3109 | 
node_modules\angular-resource\   |  7.77 |  0 |  3.13 |  8.11 |    | 
    angular-resource.js     |  6.81 |  0 |  3.13 |  7.1 |... 836,839,842 | 
    index.js        |  100 |  100 |  100 |  100 |    | 
node_modules\angular-scroll\   |  4.98 |  1.81 |  0 |  5.14 |    | 
    angular-scroll.js      |  4.09 |  1.81 |  0 |  4.22 |... 620,621,624 | 
    index.js        |  100 |  100 |  100 |  100 |    | 
node_modules\angular-ui-router\release\ | 11.21 |  0.41 |  0.35 | 12.77 |    | 
    angular-ui-router.js     | 11.21 |  0.41 |  0.35 | 12.77 |... 0,4602,4603 | 
node_modules\angular\     | 17.58 |  5.43 |  13.7 |  17.9 |    | 
    angular.js        | 17.56 |  5.43 |  13.7 | 17.88 |... 30418,30423 | 
    index.js        |  100 |  100 |  100 |  100 |    | 
node_modules\webpack\buildin\   |  100 |  50 |  50 |  100 |    | 
    module.js 

Моя карма Config является:

// jshint ignore: start 
// jscs:disable 

// Global karma config 
'use strict'; 


// START_CONFIT_GENERATED_CONTENT 
// We want to re-use the loaders from the dev.webpack.config 
var webpackConfig = require('./../webpack/webpack.test.config.js'); 
var preprocessorList = ['webpack', 'sourcemap']; 

var karmaConfig = { 
    plugins: [ 
    'karma-phantomjs-launcher', 
    'karma-jasmine', 
    'karma-junit-reporter', 
    'karma-coverage', 
    'karma-chrome-launcher', 
    'karma-webpack', 
    'karma-sourcemap-loader', 
    'karma-threshold-reporter', 
    'karma-htmlfile-reporter', 
    'karma-babel-preprocessor' 
    ],  
    files: [ 
    'node_modules/jquery/dist/jquery.js', 
    'node_modules/phantomjs-polyfill/bind-polyfill.js', 
    'config/testUnit/test.files.js' 
    ],  
    preprocessors: {   
    'config/testUnit/test.files.js': preprocessorList, 
    'src/**/!*spec.js': ['coverage'], 
    'src/app/**/*.js': ['coverage'], 
    }, 
    reporters: ['progress', 'junit', 'coverage', 'threshold','html'],  
    coverageReporter: { 
    dir: 'reports/coverage', 
    includeAllSources:false, 
    reporters: [ 
     { type: 'cobertura', subdir: 'cobertura' }, 
     { type: 'lcovonly', subdir: 'lcov' }, 
     { type: 'html', subdir: 'html' }, 
     { type: 'json', subdir: 'json' }, 
     { type: 'text' } 
    ] 
    },  
    junitReporter: { 
    outputDir: 'reports/unit/', 
    outputFile: 'test-results.xml' 
    }, 
    htmlReporter: { 
    outputFile: 'reports/unit/Test-Results.html' 
    },  
    webpack: { 
    // Load the source code using test.files.js 
    entry: {},  
    module: { 
     preLoaders: webpackConfig.module.preLoaders, 
     postLoaders: [ { //delays coverage til after tests are run, fixing transpiled source coverage error 
      test: /\.js$/, 
      exclude: /(test|node_modules|bower_components)\//, 
      loader: 'istanbul-instrumenter' } ], 
     loaders: webpackConfig.module.loaders 
    }, 
    plugins: webpackConfig.plugins.concat([new DefinePlugin({ 
     __karmaTestSpec: testFilesRegEx 
    })]), 
    resolve: webpackConfig.resolve, 
    devtool: 'inline-source-map'  // Changed to allow the sourcemap loader to work: https://github.com/webpack/karma-webpack 
    },  
    webpackServer: { 
    noInfo: true 
    },  
    singleRun: false, 
    colors: true 
};  
module.exports = karmaConfig; 

Я пробовал исключить:/(test | node_modules | bower_components) // но это не помогает.

Как исключить эти файлы из отчета о покрытии?

+0

Что вы конфиг настроить освещение? – loganfsmyth

+0

Добавлен конфиг karma в вопрос –

ответ

0

Мы можем исключить папку/файл, используя '!' нотации. Пример

preprocessors: { 
    'framework/**/!(node_modules|test|bower_components)/*.js': 'coverage'  
} 

Подробнее см - https://karma-runner.github.io/0.12/config/configuration-file.html

+0

Удаление '/' в 'webpack'' postLoaders' exclude помогло в устранении проблемы –

+0

Я работаю над windows env. Таким образом, '/' был виновником –

Смежные вопросы