Base solution for your next web application
Open Closed

Angular App - Unit Test cases not capturing coverage report #11500


User avatar
0
CLIT created

Hi Team,

Failing to Crome browser open while running test case even after two attempts & just giving up, no test cases are picked during execution time & also coverage is not generated.

Getting below error: 09 03 2023 13:09:34.690: ERROR [karma-server]: Server start failed on port 9876: Error: The '@angular-devkit/build-angular/plugins/karma' karma plugin is meant to be used from within Angular CLI and will not work correctly outside.

09 03 2023 13:21:27.204 ERROR [karma-server]: UnhandledRejection

Project Version Details: * ASP.NET Core + Angular

  • Version: v8.1.0

Not sure if it's because any package needs to be updated? or I am missing some configuration. Please help me with the same.

Below is Angular.js configuration "devDependencies": { ** "@angular-devkit/build-angular": "~0.901.0",** "@angular/cli": "^9.1.0", "@angular/compiler-cli": "^9.1.0", "@angularclass/hmr": "^2.1.3", "@angularclass/hmr-loader": "^3.0.4", "@types/jasmine": "~3.5.10", "@types/jasminewd2": "^2.0.8", "@types/jspdf": "^1.3.3", "@types/lodash": "^4.14.149", "@types/moment-timezone": "^0.5.13", "@types/node": "^13.9.5", "codelyzer": "^5.2.2", "devextreme-cldr-data": "^1.0.3", "globalize": "^1.6.0", "gulp": "^4.0.1", "gulp-clean-css": "^4.3.0", "gulp-concat": "^2.6.1", "gulp-less": "^4.0.1", "gulp-postcss": "^8.0.0", "gulp-uglify": "^3.0.2", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "^5.0.1", "karma": "^4.4.1", "karma-chrome-launcher": "~3.1.0", "karma-cli": "~2.0.0", "karma-coverage-istanbul-reporter": "^2.1.1", "karma-jasmine": "~3.1.1", "karma-jasmine-html-reporter": "^1.5.3", "merge-stream": "^2.0.0", "nswag": "13.3.0", "postcss-url": "^9.0.0", "protractor": "~5.4.3", "ts-node": "~8.8.1", "tslint": "~6.1.0", "typescript": "3.8.3"

Below is Karma.config.js // Karma configuration file, see link for more information // https://karma-runner.github.io/0.13/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-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), require('@angular-devkit/build-angular/plugins/karma') ], client:{ clearContext: false // leave Jasmine Spec Runner output visible in browser }, files: [

],
preprocessors: {
  
},
mime: {
  'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
  dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
  fixWebpackSourcePaths: true
},
angularCli: {
  environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
          ? ['progress', 'coverage-istanbul']
          : ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false

}); };

Thanks CL-IT


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have created an issue about this problem, please follow https://github.com/aspnetzero/aspnet-zero-core/issues/4773

  • User Avatar
    0
    CLIT created

    HI Team,

    Please help with some solution I am kind of stuck & looking for some solution to proceed.

    Thanks CL-IT

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @CLIT

    We haven't started to work on this issue but we will work on it in a short time. I have assigned high priority to this item.