2

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

此图显示延迟

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

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);

};

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

"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”、“业力铬启动器”:“^2.0.0”、“业力-cli": "1.0.1",“业力覆盖”:“^1.1.1”,“业力火狐启动器”:“^1.0.1”,“业力-茉莉花”:“^1.1.0”,“业力-茉莉花-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”}

请指教!

谢谢!

4

0 回答 0