1 year ago

#320639

test-img

ATP

Unit test cases are not running after upgrading to Angular 12

Upgraded project from Angular version 5 to 12. The project is running fine but the unit test cases are not running, and just showing

Karma v 6.3.17 - connected; test: execute;

PhantomJS 2.1.1 (Windows 8) is idle

Chrome 99.0.4844.74 (Windows 10) is idle

enter image description here Tried on Firefox also but still the same result.

karma.conf.js

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
    config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular-devkit/build-angular'],
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
            require('karma-firefox-launcher'),
            require('karma-phantomjs-launcher'),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter'),
            require('karma-junit-reporter'),
            require('@angular-devkit/build-angular/plugins/karma')
        ],
        browserDisconnectTimeout: 100000,
        browserNoActivityTimeout: 100000,
        browserDisconnectTolerance: 10,
        client:{
            clearContext: false, // leave Jasmine Spec Runner output visible in browser
            captureConsole: true
        },
        coverageIstanbulReporter: {
            dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly', 'text', 'text-summary' ],
            fixWebpackSourcePaths: true,
            thresholds: {
                emitWarning: false,
                global: {
                    statements: 45,
                    lines: 45,
                    branches: 22,
                    functions: 35
                }
            }
        },
        angularCli: {
            environment: 'dev'
        },
        junitReporter: {
            outputDir: 'sf-unit-report',
            outputFile: 'result.xml',
            useBrowserName: false
        },
        reporters: ['progress', 'kjhtml'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome','firefox'],
        singleRun: false
    });
};

versions of karma and jasmine

 "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.17",
    "karma-chrome-launcher": "~3.1.1",
    "karma-cli": "~2.0.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-firefox-launcher": "~1.0.1",
    "karma-jasmine": "~1.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "karma-junit-reporter": "^1.2.0",
    "karma-phantomjs-launcher": "~1.0.4",

Changed different versions of karma and jasmine, tried deleting node modules and running npm install again. Was expecting some errors of unit test or some configuration error logs

angular

karma-jasmine

karma-runner

angular12

angular-upgrade

0 Answers

Your Answer

Accepted video resources