首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >业力+褐变+茉莉花+伊斯坦布尔+反应覆盖

业力+褐变+茉莉花+伊斯坦布尔+反应覆盖
EN

Stack Overflow用户
提问于 2015-10-22 16:21:33
回答 1查看 1.3K关注 0票数 9

我试图为我的测试获得覆盖报告,但是所有文件的覆盖率输出总是在一行上,用路径显示文件的要求。例如..。

然而,这些测试运行良好。这是一个react项目,所以我必须包括一些文件和预处理器的附加路径才能运行测试。

我不确定我的业力配置有什么问题吗?这就是我现在的配置.

代码语言:javascript
复制
/* global module */
module.exports = function (config) {
    'use strict';
    config.set({
        autoWatch: true,
        singleRun: true,

        frameworks: ['browserify', 'jasmine'],

        files: [
            'node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js',
            'node_modules/react/react.js',
            'src/**/*.jsx',
            'src/**/!(*spec).js'
        ],

        browsers: ['PhantomJS'],

        preprocessors: {
            'node_modules/react/react.js': ['browserify', 'sourcemap'],
            'src/**/*.jsx': ['browserify', 'sourcemap', 'coverage'],
            'src/**/!(*spec).js': ['browserify', 'sourcemap', 'coverage'],
        },

        browserify: {
            debug: true,
            transform: [ 'babelify' ]
        },

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

        coverageReporter: {
            instrumenters: {isparta: require('isparta')},
            instrumenter: {
                'src/**/*.js': 'isparta',
                'src/**/*.jsx': 'isparta'

            },
            reporters: [
                {
                    type: 'text-summary',
                    subdir: normalizationBrowserName
                },
                {
                    type: 'lcov',
                    subdir: normalizationBrowserName
                },
                {
                    type: 'html',
                    dir: 'coverage/',
                    subdir: normalizationBrowserName
                }
            ]
        }

    });

    function normalizationBrowserName(browser) {
        return browser.toLowerCase().split(/[ /-]/)[0];
    }

};

更新:--我也使用了一个公共as转换--并且能够让事情更好地工作,但是测试不能运行,而覆盖率就是转换的代码。

EN

回答 1

Stack Overflow用户

发布于 2015-10-22 20:05:26

确保包含覆盖范围的所有源代码。例如,我有以下karma.conf.js:(检查预处理部分)

代码语言:javascript
复制
// Karma configuration
// Generated on Mon Sep 07 2015 23:22:13 GMT-0400 (Eastern Daylight Time)

module.exports = function(config) {

    var SourceCode = [
        'app/app.js',
        'app/Modules/*.js',                     // Basic Path Files (Modules for Source, UnitTests to keep test files separate)
        'app/Modules/**/_*.init.js',            // Declarative functions needed for next line - Initialization Code
        'app/Modules/**/*.js',
        'app/UnitTests/**/*.mock.js',           // Mock Declarations for Tests
        'app/UnitTests/**/*.test.js'
    ];

    var Libraries = [
        'app/bower_components/angular/angular.js',
        'app/bower_components/angular-animate/angular-animate.js',
        'app/bower_components/angular-aria/angular-aria.js',
        'app/bower_components/angular-route/angular-route.js',
        'app/bower_components/firebase/firebase.js',
        ...
// Testing
        'app/bower_components/angular-mocks/angular-mocks.js',
        'app/bower_components/angular-material/angular-material-mocks.js',
        'app/bower_components/mockfirebase/browser/mockfirebase.js',
        'node_modules/sinon/pkg/sinon.js',
    ];

    config.set({
        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',


        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['mocha', 'chai'],      // 


        // list of files / patterns to load in the browser
        files: Libraries.concat(SourceCode),


        // list of files to exclude
        exclude: [
        ],


        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {
            'app/Modules/**/*.js': ['coverage']          // Ensure all files are in Code Coverage
        },

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', 'coverage'],    

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

        logLevel: 'LOG_DEBUG',

        // web server port
        port: 9876,


        // enable / disable colors in the output (reporters and logs)
        colors: true,


        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,


        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,


        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['PhantomJS'],    // 'Chrome', 


        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: true
    })
}
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33285823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档