0

유닛 테스트를 실행하기 위해 카르마를 사용 중이며 karma-coverage을 프로세스에 통합하려고합니다. singleRun: true으로 테스트를 실행하려면 PhantomJS을 사용하고 있습니다. 이 작업을 수행 할 때마다 코드 커버리지 리포터가 실행되지 않는 것처럼 보입니다. singleRun: false으로 설정하면 폴더와 파일이 만들어집니다.singleRun = true 일 때 karma-coverage 파일이 작성되지 않았습니다.

karma coverage tool이 실행되지 않는 이유는 무엇입니까?

module.exports = function (config) { 
    config.set({ 
    basePath: '', 
    frameworks: ['mocha', 'requirejs', 'sinon-chai'], 
    files: [ 
    { pattern: 'bower_components/angular/angular.js', included: false }, 
    { pattern: 'bower_components/jquery/dist/jquery.js', included: false }, 
    { pattern: 'bower_components/angular-mocks/angular-mocks.js', included: false }, 
    { pattern: '**/*.js', included: false }, 
    { pattern: 'KarmaTests/test-main.js', included: true }, 
    { pattern: 'KarmaTests/**/*Test*.js', included: false } 
    ], 

    preprocessors: { 
     'KarmaTests/*/*.js': ['coverage'] 
    }, 

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

    coverageReporter: { 
     type: 'html', 
     dir: '_testCoverage/', 
     file: 'cover.html' 
    }, 

    port: 9876, 
    colors: true, 
    logLevel: config.LOG_INFO, 
     autoWatch: true, 

     browsers: ['PhantomJS'], 

     //files are created when false, are not when true 
     singleRun: false 
    }); 
}; 
+0

어떤 버전입니까? '카르마 '의 시온은 당신이 사용하고 있습니까? – MarcoL

답변

0

처리기는 원본 파일이 아닌 테스트 파일을지도하기위한 것입니다 :

여기 내 설정 파일입니다. 에

  • 변경 처리기 패턴 : 다음을 수행

    preprocessors: { 
         '/**/*.js': ['coverage'] 
        }, 
    
  • 을 그리고 테스트 매핑에 JS 파일을 추가 :

    { pattern: '**/*.js', included: true } 
    
  • 다시 실행 카르마과 결과를 볼

관련 문제