Karma-sonarqube-unit-reporter - Issue in running code-coverage for Angular project

We are trying to run code coverage for Angular project using karma-sonarqube-unit-reporter along with Sonar-scanner.

ng test --watch=false --code-coverage

Getting below error while running above command.

Error:
05 07 2021 18:16:45.109:ERROR [karma-server]: UncaughtException: TypeError: Cannot read property ‘value’ of undefined
at SonarQubeUnitReporter.specSuccess.specSkipped.specFailure (C:\2021\04.CodeCoverage\Tools\Angular1\testing\node_modules\karma-sonarqube-unit-reporter\index.js:154:95)
at SonarQubeUnitReporter.BaseReporter.onSpecComplete (C:\2021\04.CodeCoverage\Tools\Angular1\testing\node_modules\karma\lib\reporters\base.js:107:12)
at Server. (C:\2021\04.CodeCoverage\Tools\Angular1\testing\node_modules\karma\lib\events.js:40:26)
at Server.emit (events.js:387:35)
at Browser.onResult (C:\2021\04.CodeCoverage\Tools\Angular1\testing\node_modules\karma\lib\browser.js:164:20)
at Socket. (C:\2021\04.CodeCoverage\Tools\Angular1\testing\node_modules\karma\lib\browser.js:218:42)
at Socket.emit (events.js:375:28)
at C:\2021\04.CodeCoverage\Tools\Angular1\testing\node_modules\socket.io\dist\socket.js:435:32
at processTicksAndRejections (internal/process/task_queues.js:77:11)

sonarQubeUnitReporter config:
sonarQubeUnitReporter: {
sonarQubeVersion: ‘LATEST’,
outputFile: ‘reports/ut_report.xml’,
overrideTestDescription: true,
testPaths: [‘src/testing’],
testFilePattern: ‘.ts’,
useBrowserName: false
},
reporters: [‘sonarqubeUnit’],

Hi Mathi,

I’ve had success in the past using karma-coverage-istanbul-reporter, example project here. It outputs coverage in the standard lcov format, which we support.

I’m not sure who created karma-sonarqube-unit-reporter, but it’s not a SonarSource artifact.

Thank you Jeff. we will try with karma-coverage-istanbul-reporter.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.