karma-sonarqube-unit-reporter icon indicating copy to clipboard operation
karma-sonarqube-unit-reporter copied to clipboard

Add append formatter option

Open jeubank12 opened this issue 5 years ago • 0 comments

Add option to append a filenameFormatter. This could be extended in the future to accept a prepend option. I could not think of a use for prepend since it would modify the test name before the default formatter had a chance to modify it. Another acceptable solution would be to overload 'overrideTestDescription' with the option, but the meaning of 'append' vs 'prepend' was vague (does append mean that the override is before or after the custom formatter?)

Usage: To append a formatter (i.e. let the default reporter convert to a filename and then modify the result of that) karma.conf.js:

sonarQubeUnitReporter: {
  sonarQubeVersion: 'LATEST',
  overrideTestDescription: true,
// note that at the time of this writing, leaving testFilePattern unspecified results in a runtime exception
  testFilePattern: '.spec.ts',
  filenameFormatter: function(nextPath, result) {
    return 'customPathPrefix/' + nextPath
  },
  addFilenameFormatter: 'append'
}

jeubank12 avatar Nov 25 '19 17:11 jeubank12