Ionic 3和Angular 4 - Karma不会立即运行单元测试。开始需要一分钟或更长时间。什么导致缓慢?

时间:2018-01-08 19:59:10

标签: angular unit-testing karma-runner ionic3 karma-webpack

使用Ionic 3和Angular 4 - Karma Test Runner不会立即运行单元测试。开始需要大约一分钟或更长时间。这是正常的还是我可以做些什么来加快它?

This image shows the delay

以下是我正在使用的业力配置文件

module.exports =(config)=> {

var testWebpackConfig = require('./webpack.test.js')({});

const configuration = {

    // base path that will be used to resolve all patterns (e.g. files, exclude)
    basePath: '',
    frameworks: ['jasmine'],
    files: [
        {pattern: './config/karma-shim.js', watched: false},
        { pattern: './src/assets/**/*', watched: false, included: false, served: true, nocache: false }],
    preprocessors: { './config/karma-shim.js': ['coverage', 'webpack', 'sourcemap'] },
    webpack: testWebpackConfig,
    webpackMiddleware: {
        // webpack-dev-middleware configuration
        // i.e.
        noInfo: true,
        // and use stats to turn off verbose output
        stats: {
            // options i.e.
            chunks: false
        }
    },
    reporters: [ 'mocha' ],
    port: 9876,
    captureTimeout: 60000,
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 3,
    browserNoActivityTimeout: 60000,
    colors: true,
    client: {
        captureConsole: false
    },
    /*
     * By default all assets are served at http://localhost:[PORT]/base/
     */
    proxies: {
        "/assets/": "/base/src/assets/"
    },
    /*
     * level of logging
     * possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
     */
    logLevel: config.LOG_DEBUG,
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,
    /*
     * start these browsers
     * available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
     */
    customLaunchers: {
        ChromeHeadless: {
            base: 'Chrome',
            flags: [
                '--headless',
                '--disable-gpu',
                '--disable-translate',
                '--disable-extensions',
                // Without a remote debugging port, Google Chrome exits immediately.
                '--remote-debugging-port=9222',
            ],
        }
    },
    browsers: [
        'ChromeHeadless'
    ],
    singleRun: false
};

if(process.env.NO_COVERAGE !== 'true') {
    configuration.reporters.push( 'coverage', 'remap-coverage');
    configuration.coverageReporter = {
        type: 'in-memory'
    };

    configuration.remapCoverageReporter = {
        'text-summary': null,
        html: './coverage/istanbul'
    };
}


config.set(configuration);

};

以下是我正在使用的依赖项和dev依赖项。

"dependencies": {
"@angular/common": "4.4.4",
"@angular/compiler": "4.4.4",
"@angular/compiler-cli": "4.4.4",
"@angular/core": "4.4.4",
"@angular/forms": "4.4.4",
"@angular/http": "4.4.4",
"@angular/platform-browser": "4.4.4",
"@angular/platform-browser-dynamic": "4.4.4",
"@ionic-native/core": "4.3.2",
"@ionic-native/splash-screen": "4.3.2",
"@ionic-native/status-bar": "4.3.2",
"@ionic/storage": "2.0.1",
"angular2-text-mask": "8.0.2",
"ibm-mfp-web-sdk": "8.0.2017091403",
"intl": "^1.2.5",
"ionic-angular": "3.8.0",
"ionicons": "3.0.0",
"moment": "2.18.1",
"rxjs": "5.4.3",
"sw-toolbox": "3.6.0",
"text-mask-addons": "^3.6.0",
"zone.js": "0.8.18"

},       “devDependencies”:{     “@ ionic / app-scripts”:“1.3.7”,     “@ ionic / cli-plugin-cordova”:“1.6.2”,     “@ types / jasmine”:“^ 2.5.47”,     “@ types / node”:“^ 7.0.15”,     “angular2-template-loader”:“^ 0.6.2”,     “awesome-typescript-loader”:“3.1.3”,     “codelyzer”:“3.1.2”,     “同时”:“^ 3.4.0”,     “html-loader”:“^ 0.4.5”,     “istanbul-instrumenter-loader”:“^ 2.0.0”,     “jasmine-core”:“^ 2.6.1”,     “jasmine-spec-reporter”:“^ 4.1.0”,     “业力”:“^ 1.6.0”,     “karma-chrome-launcher”:“^ 2.0.0”,     “karma-cli”:“1.0.1”,     “业力报道”:“^ 1.1.1”,     “karma-firefox-launcher”:“^ 1.0.1”,     “karma-jasmine”:“^ 1.1.0”,     “karma-jasmine-html-reporter”:“^ 0.2.2”,     “karma-mocha-reporter”:“^ 2.2.3”,     “karma-remap-coverage”:“^ 0.1.4”,     “karma-sourcemap-loader”:“^ 0.3.7”,     “karma-webpack”:“^ 2.0.3”,     “null-loader”:“^ 0.1.1”,     “raw-loader”:“^ 0.5.1”,     “source-map-loader”:“^ 0.2.1”,     “ts-helpers”:“^ 1.1.2”,     “ts-loader”:“^ 2.0.3”,     “ts-node”:“^ 3.0.2”,     “tslint”:“^ 5.2.0”,     “tslint-loader”:“^ 3.5.3”,     “打字稿”:“2.2.1” }

请指教!

谢谢!

0 个答案:

没有答案