2

Using Ionic 3 and Angular 4 - Karma Test Runner does not run the unit tests instantly. It takes about a minute or above to start. Is this normal or there is something I can do to speed it up?

This image shows the delay

Following is the karma config file I am using

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

};

Following are the dependencies and dev dependencies I am using.

"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", "concurrently": "^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", "karma": "^1.6.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "1.0.1", "karma-coverage": "^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", "typescript": "2.2.1" }

Please advise!

Thanks!

Jini Thakker
  • 23
  • 1
  • 6

0 Answers0