How to get jarm messages

Is there a karma reporter that can be used to create a results.xml file that is compatible with the Generic Test Coverage plugin? Or, alternatively, a parser for a junit file that is output by karma-junit-reporter and which will work with a common plugin?

I am using SonarQube 5.3 and Karma / Jasmine

I want to import junit reports that come from karma into SonarQube, but I see no way to do this easily. Something like https://www.npmjs.com/package/mocha-sonar-generic-test-coverage for karma

FYI I saw karma-junit-sonarqube-reporter ( https://www.npmjs.com/package/karma-junit-sonarqube-reporter ), but it looks like the name of the test matches the file path, which limits me too much, karma-sonarqube-unit-reporter seems unfinished grunt-karma-sonar seems to rely on jstestdriver which is deprecated

+5
source share
1 answer

I managed to achieve this by following these steps.

Get javascript junit reports in sonar

  • find and download sonar-karma-test-report-plugin-1.0.0.4.jar , which is not available through the update center
  • put the jar file in /usr/local/Cellar/sonar/5.3/libexec/extensions/plugins and restart the sonar
  • Tell karma to omit browser name

     junitReporter: { useBrowserName: false } 
  • Get Karma to create a junit xml file using the regular karma-junit-reporter and ask him to call the TESTS-xunit.xml (I had a file called test-results.xml , but the sonar did not detect its WTF)

  • In sonar-project.properties file sonar.javascript.karmajstestdriver.reportsPath=reports/js/unit-components/results/

  • call sonar-runner

Sonar requires a test file path to process the report. Jasmine does not make this available to the reporter. My understanding is that the sonar plugin iterates over the xml file and finds the class name for each test that has a test name (i.e. my cool tests ) and replaces the line to change it to the file location

+5
source

Source: https://habr.com/ru/post/1242334/


All Articles