karma coverage
v2.2.1
이스탄불을 사용하여 코드 적용 범위를 생성합니다.
가장 쉬운 방법은 실행하여 devDependency
으로 karma-coverage
설치하는 것입니다.
npm install karma karma-coverage --save-dev
구성 세부 정보는 문서/구성을 참조하십시오.
// karma.conf.js
module . exports = function ( config ) {
config . set ( {
files : [
'src/**/*.js' ,
'test/**/*.js'
] ,
// coverage reporter generates the coverage
reporters : [ 'progress' , 'coverage' ] ,
preprocessors : {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'src/**/*.js' : [ 'coverage' ]
} ,
// optionally, configure the reporter
coverageReporter : {
type : 'html' ,
dir : 'coverage/'
}
} ) ;
} ;
커피 스크립트와 함께 사용하는 방법에 대한 예는 예/커피를 참조하십시오. CoffeeScript 및 InquessJS 모듈 로더와 함께 사용하는 방법의 예는 예/Coffee-RequireJS를 참조하십시오 (또한 Docs/Configuration.md의 useJSExtensionForCoffeeScript
옵션도 참조하십시오).
// karma.conf.js
module . exports = function ( config ) {
config . set ( {
files : [
'src/**/*.js' ,
'test/**/*.js'
] ,
reporters : [ 'progress' , 'coverage' ] ,
preprocessors : {
'src/**/*.js' : [ 'coverage' ]
} ,
coverageReporter : {
// specify a common output directory
dir : 'build/reports/coverage' ,
reporters : [
// reporters not supporting the `file` property
{ type : 'html' , subdir : 'report-html' } ,
{ type : 'lcov' , subdir : 'report-lcov' } ,
// reporters supporting the `file` property, use `subdir` to directly
// output them in the `dir` directory
{ type : 'cobertura' , subdir : '.' , file : 'cobertura.txt' } ,
{ type : 'lcovonly' , subdir : '.' , file : 'report-lcovonly.txt' } ,
{ type : 'teamcity' , subdir : '.' , file : 'teamcity.txt' } ,
{ type : 'text' , subdir : '.' , file : 'text.txt' } ,
{ type : 'text-summary' , subdir : '.' , file : 'text-summary.txt' } ,
]
}
} ) ;
} ;
ISTANBUL Instrumenter (기본값)를 사용하는 경우 구성에 다음을 추가하여 코드 압축을 비활성화 할 수 있습니다.
// karma.conf.js
module . exports = function ( config ) {
config . set ( {
coverageReporter : {
instrumenterOptions : {
istanbul : { noCompact : true }
}
}
} ) ;
} ;
카르마에 대한 자세한 내용은 홈페이지를 참조하십시오.