Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 2x 6x 4x 4x 4x 2x 2x | import { XMLParser } from 'fast-xml-parser';
import type { BaseParser, Results } from './base';
import * as is from '../guards';
import { extname } from 'path';
import type { CoberturaReport } from '../guards/xml';
export class CoberturaParser implements BaseParser<CoberturaReport> {
globs = ['**/*/cobertura.xml', 'cobertura.xml', '**/*/*coverage.xml', '*coverage.xml'];
matches(name: string, contents: string) {
if (extname(name) !== '.xml') return false;
const parser = new XMLParser({
ignoreAttributes: false,
parseAttributeValue: true,
});
const result = parser.parse(contents);
return is.xml.cobertura(result) ? result : false;
}
public parse(report: CoberturaReport): Results {
return {
branches: report.coverage['@_branch-rate'],
// Does covertura even support this?
functions: report.coverage['@_line-rate'],
lines: report.coverage['@_line-rate'],
};
}
}
export const cobertura = new CoberturaParser();
|