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
feature (reporter): issue #1814 Add json reporter #2601
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dance-cmdr for this PR. I've got some remarks. Do you still have time to fix them? If not, we can merge it in and I can change it before we release 4.2.
@@ -0,0 +1,19 @@ | |||
import * as path from 'path'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a duplication of the code in html-reporter-util.ts
. Can we rename that file to reporter-util
and reuse the writeFile
implementation from that file?
"baseDir": { | ||
"description": "The output folder for the json report.", | ||
"type": "string", | ||
"default": "reports/mutation/json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the JSON report will be a single file, I think it makes sense to default to reports/mutation
here. So
@@ -349,6 +361,10 @@ | |||
"description": "The options for the html reporter", | |||
"$ref": "#/definitions/htmlReporterOptions" | |||
}, | |||
"jsonReporter": { | |||
"description": "The options for the json reporter", | |||
"$ref": "#/definitions/jsonReporterOptions" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fill the default
here with {}
. That way, you don't need to check if options.
jsonReporter` is null later, or duplicate the default value of "jsonReporterOptions.baseDir".
this.log.info(`Your report can be found at: ${fileUrl(indexFileName)}`); | ||
} | ||
|
||
private get baseDir(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As stated earlier, this null check is no longer needed if you use "default": {}
for the jsonReporter
option. The base dir inside the StrykerOptions
will always be filled with a string.
} | ||
|
||
private async cleanBaseFolder(): Promise<void> { | ||
await deleteDir(this.baseDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to delete the baseDir
, since it is a single file report. We will just override this file whenever onMutationTestingReportReady
is called.
@@ -102,7 +102,8 @@ | |||
"preprocessors", | |||
"serializable", | |||
"surrialize" | |||
] | |||
], | |||
"compile-hero.disable-compile-files-on-did-save-code": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That went in by mistake. It's a markdown plugin I have.
@dance-cmdr Nice to see that you are back and gave this another shot :) |
Hey, this is part of a project I'm doing and I didn't know if your PR is still active and I didn't feel confident to check out your branch. |
Thanks for the help, but since then merged with #2582 |
This is a solution for issue #1814 that I opened ages ago! This is my second attempt!
I used HTML reporter as the guideline and tried to keep the code as faithfully to current code style as possible.
It is a very simple solution. I just dump the
report: MutationTestResult
POJO that is generatedonMutationTestReportReady
in a JSON file.json-reporter-util.ts
is almost the same ashtml-reporter-util.ts
but I decided to go with it because I didn't know if you'd like to generalise and move file handling util functions outside reporters.Please drop me a line If I've done something wrong!!!