All files / istanbul-lib-report/src/reports/lcov index.ts

25% Statements 3/12
0% Branches 0/4
33.33% Functions 1/3
25% Lines 3/12

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 35 36 37 38 39 40 41 42 43                                              9x 45x 45x                                  
/*
 Copyright 2012-2015, Yahoo Inc.
 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
 */
import ReportBase from "../../report-base";
import HtmlReport from "../html/index";
import LcovOnlyReport from "../lcovonly/index";
import type { LcovOnlyOptions } from "../lcovonly/index";
 
/** options accepted by {@link LcovReport}, passed through to the lcovonly report */
export interface LcovOptions extends LcovOnlyOptions {}
 
class LcovReport extends ReportBase {
  declare lcov: LcovOnlyReport;
  declare html: HtmlReport;
 
  constructor(opts?: LcovOptions) {
    super();
    this.lcov = new LcovOnlyReport({ file: "lcov.info", ...opts });
    this.html = new HtmlReport({ subdir: "lcov-report" });
  }
}
 
["Start", "End", "Summary", "SummaryEnd", "Detail"].forEach((what) => {
  const meth = "on" + what;
  (LcovReport.prototype as unknown as Record<string, unknown>)[meth] = function (
    this: LcovReport,
    ...args: unknown[]
  ) {
    const lcov = this.lcov as unknown as Record<string, undefined | ((...a: unknown[]) => void)>;
    const html = this.html as unknown as Record<string, undefined | ((...a: unknown[]) => void)>;
 
    if (lcov[meth]) {
      lcov[meth](...args);
    }
    if (html[meth]) {
      html[meth](...args);
    }
  };
});
 
export default LcovReport;