Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add append formatter option #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeubank12
Copy link

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'
}

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:
```javascript
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'
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant