Skip to content

Commit

Permalink
update type
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Dec 3, 2023
1 parent 598b8cc commit d9a760e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
49 changes: 38 additions & 11 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,51 @@ export type IstanbulReportConfig = {
options: any
}

// https://playwright.dev/docs/api/class-coverage
export type CoverageEntry = {
url: string,
// css
text?: string,
ranges?: any[]
// js
scriptId?: string,
source?: string,
functions?: any[]
}

export type CoverageReportOptions = {

// report name (V8 only)
name?: string,
outputFile?: string,

// Whether to convert to Istanbul report
// output dir and filename (filename V8 only)
outputFile?: string | (() => string),

// logging levels: off, error, info, debug
logging?: string,

// (Boolean) Whether to convert to Istanbul report from V8 list. Defaults to `html-spa` report. (V8 only)
// (String) Istanbul report name
// (Array) multiple reports. ["report-name", { name: "report-name", options: {} }, ...]
toIstanbul?: boolean | string | string[] | IstanbulReportConfig[],

// A filter function to execute for each element in the V8 list.
entryFilter?: (entry: any) => boolean,
// (Boolean) Whether to create `lcov.info`. (for Sonar coverage)
lcov?: boolean,

// A filter function to execute for each element in the sources which unpacked from the source map.
// (Function) A filter function to execute for each element in the V8 list. (V8 only)
entryFilter?: (entry: CoverageEntry) => boolean,

// (Function) A filter function to execute for each element in the sources which unpacked from the source map. (Sourcemap only)
sourceFilter?: (sourcePath: string) => boolean,

sourcePath?: (sourcePath: string) => string,
// (Function) source path handler. (Istanbul only)
sourcePath?: (filePath: string) => string,

// (Function) source finder for Istanbul HTML report. (Istanbul only)
sourceFinder?: (filePath: string) => string,

// Whether to create `lcov.info`
lcov?: boolean,

// (Array) watermarks for low/medium/high. Defaults to [50, 80]
// (Object) Istanbul: { statements:[50,80], functions:[50,80], branches:[50,80], lines:[50,80] }, V8: { bytes:[50,80] }.
watermarks?: [number, number] | {
statements?: [number, number],
functions?: [number, number],
Expand All @@ -32,10 +56,11 @@ export type CoverageReportOptions = {
bytes?: [number, number]
},

// Whether inline all scripts to the single HTML file.
// (Boolean) Whether inline all scripts to the single HTML file. (V8 only)
inline?: boolean,

logging?: string
// assets path if not inline. (V8 only)
assetsPath?: string
};

export class CoverageReport {
Expand All @@ -44,4 +69,6 @@ export class CoverageReport {
generate: () => Promise<any>;
}

export default CoverageReport;

export function createCoverageReport(options?: CoverageReportOptions): CoverageReport;
4 changes: 2 additions & 2 deletions lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ module.exports = {
// sourceFilter: (sourcePath) => sourcePath.search(/src\/.+/) !== -1,
sourceFilter: null,

// source path handler. (Istanbul only)
// (Function) source path handler. (Istanbul only)
// sourcePath: (filePath) => `wwwroot/${filePath}`,
sourcePath: null,

// (usually not used) source finder for Istanbul HTML report. (Istanbul only)
// (Function) source finder for Istanbul HTML report. (Istanbul only)
// sourceFinder: (filePath) => `src/${filePath}`,
sourceFinder: null,

Expand Down

0 comments on commit d9a760e

Please sign in to comment.