@stryker-mutator/core
Version:
The extendable JavaScript mutation testing framework
29 lines • 1.07 kB
JavaScript
import path from 'path';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { pathToFileURL } from 'url';
import { reporterUtil } from './reporter-util.js';
const INDENTION_LEVEL = 0;
export const RESOURCES_DIR_NAME = 'strykerResources';
export class JsonReporter {
options;
log;
mainPromise;
constructor(options, log) {
this.options = options;
this.log = log;
}
static inject = tokens(commonTokens.options, commonTokens.logger);
onMutationTestReportReady(report) {
this.mainPromise = this.generateReport(report);
}
wrapUp() {
return this.mainPromise;
}
async generateReport(report) {
const filePath = path.normalize(this.options.jsonReporter.fileName);
this.log.debug(`Using relative path ${filePath}`);
await reporterUtil.writeFile(path.resolve(filePath), JSON.stringify(report, null, INDENTION_LEVEL));
this.log.info(`Your report can be found at: ${pathToFileURL(filePath).href}`);
}
}
//# sourceMappingURL=json-reporter.js.map