Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function junitReporter(__: string, rulesUsed: linter.YAMLRule[], results: linter.RuleTrigger[], outputDir: string) {
const reportBuilder = junitReports.newBuilder();
const suite = reportBuilder.testSuite().name("replicated-lint");
const invalidYAMLError = getInvalidYAMLError(results);
for (const rule of rulesUsed) {
const testCase = suite.testCase().className("replicated-lint").name(rule.name);
if (invalidYAMLError) { // if the yaml was invalid, then all the rules should fail regardless of results
testCase.failure(invalidYAMLError.message);
continue;
}
const result = _.find(results, r => r.rule === rule.name);
if (result) {
testCase.failure(result.message);
}
prepareXml (runners) {
const builder = junit.newBuilder()
for (const key of Object.keys(runners)) {
const capabilities = runners[key]
const packageName = this.options.packageName
? `${capabilities.sanitizedCapabilities}-${this.options.packageName}`
: capabilities.sanitizedCapabilities
for (let specId of Object.keys(capabilities.specs)) {
const spec = capabilities.specs[specId]
for (let suiteKey of Object.keys(spec.suites)) {
/**
* ignore root before all
*/
/* istanbul ignore if */
if (suiteKey.match(/^"before all"/)) {
continue
function junit (errors) {
const builder = reportBuilder.newBuilder();
Object.keys(errors).forEach(fileName => {
const suite = builder.testSuite().name(fileName);
errors[fileName].forEach(error => {
const testCase = suite.testCase()
.name(`${icons[error.severity] || icons.success} ${error.message}`)
.className([error.plugin, error.rule].filter(Boolean).join(' '));
const message = `${error.fileName}:${error.lineNumber}:${error.columnNumber}`;
if (!error.severity || error.severity === 'error') {
testCase.error(message);
} else {
testCase.failure(message);
}
});
});
return fs.outputFile(reportPath(String(Date.now()), 'lint-result.xml'), builder.build());
constructor() {
this._outfile = path.resolve(process.cwd(), 'test-results.xml');
this._builder = builder.newBuilder();
}
proof.hooks.end.tapPromise('junit', async (results: SuiteResult) => {
const reportBuilder = newBuilder();
results.tests.forEach(t => {
if (!suites.has(t.story.kind)) {
suites.set(
t.story.kind,
reportBuilder.testSuite().name(t.story.kind)
);
}
const suite = suites.get(t.story.kind);
if (!suite) {
return;
}
const testCase = suite.testCase().name(t.name);
if (t.error) {
testCase.failure(t.error.message);