Покрытие кода Karma не отображается в Sonarqube - PullRequest
1 голос
/ 29 апреля 2020

Проблема : охват Sonarqube составляет 0% после того, как я настроил карму и сонар.

Arch : приложение использует Angular7 и Node v8.14, встроенный Sonarqube последняя версия и JDK: java 11.

Issue Des c: это моя локальная среда, после того как я настроил и запустил покрытие и сонар, покрытие кармой составляет 35%, но в сонаре это все еще 0%.

Пожалуйста, смотрите мой код, как показано ниже:

package.json:

  "scripts": {
    "ng": "ng",
    "start": "node server.js",
    "build": "ng build",
    "test": "ng test --code-coverage",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "sonar": "sonar-scanner"
  },
  "dependencies": {
     ...
     "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "puppeteer": "^2.0.1"
   },
  "devDependencies": {
     ...
     "sonarqube-scanner": "^2.6.0",
  }

sonar-project.properties:

sonar.projectKey=aaa
sonar.projectName=AAA
sonar.projectVersion=1.0.0
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.test.reportPath=./test-results.xml
sonar.language=ts
sonar.exclusions=**/node_modules/**
sonar.tests=src
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.test.inclusions=**/*.spec.ts

karma.conf.js:

    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    // browsers: ['ChromeHeadless'],
    // singleRun: true,
    browsers: ['Chrome'],
    singleRun: false,
    restartOnFileChange: true
  });
  ...

Покрытие кармы enter image description here

структура calss

enter image description here

эхолот enter image description here

...