karma-junit-reporter
Reporter for the JUnit XML format.
Installation
The easiest way is to keep karma-junit-reporter
as a devDependency in your package.json
. Just run
npm install karma-junit-reporter --save-dev
to let npm automatically add it there.
Configuration
// karma.conf.jsmodule { config;};
You can pass list of reporters as a CLI argument too:
karma start --reporters junit,dots
Produce test result with schema acceptable in sonar
To make this possible, it's required to make the classnames of each tests to match its file name.
For Example:
should have a file name AnalyticsModule_test.js
This will produce test result with schema acceptable in sonar.
Grunt file reporters property example:
reporters: 'junit' 'coverage' 'progress'junitReporter: outputDir: $junitResults suite: 'models'coverageReporter: type: 'lcov' dir: $coverageOutputDir subdir: '.'preprocessors: 'src/main/webapp/public/js/ec3.3/**/*.js': 'coverage' 'src/main/webapp/public/js/ec3/**/*.js': 'coverage'plugins: 'karma-jasmine' 'karma-phantomjs-launcher' 'ec-karma-junit-reporter23' 'karma-coverage'
Sonar property example:
sonarprojectName=jssonarsources=site-main-php/src/main/webapp/public/jssonarprojectBaseDir=sonarexclusions=site-main-php/src/main/webapp/public/js/lib/*.js,site-main-php/src/main/webapp/public/js/tests/**/*phpsite-main-php/src/main/webapp/public/js/tests/**/*jssite-main-php/src/main/webapp/public/js/ec33/vendor/**sonar.javascript.lcov.reportPath=site-main-php/target/coverage/lcov.infosonar.javascript.jstestdriver.reportsPath=site-main-php/target/surefire-reports/sonar.tests=site-main-php/src/main/webapp/public/js/tests
Example junit xml report:
...
For more information on Karma see the homepage.