1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import { FileCoverage, FileCoverageData, Range } from 'istanbul-lib-coverage';
|
8 | import { RawSourceMap } from 'source-map';
|
9 | import * as babelTypes from 'babel-types';
|
10 |
|
11 | export interface InstrumenterOptions {
|
12 | coverageVariable: string;
|
13 | preserveComments: boolean;
|
14 | compact: boolean;
|
15 | esModules: boolean;
|
16 | autoWrap: boolean;
|
17 | produceSourceMap: boolean;
|
18 | sourceMapUrlCallback(filename: string, url: string): void;
|
19 | debug: boolean;
|
20 | }
|
21 |
|
22 | export type InstrumenterCallback = (error: Error | null, code: string) => void;
|
23 |
|
24 | export class Instrumenter {
|
25 | fileCoverage: FileCoverage;
|
26 | sourceMap: RawSourceMap | null;
|
27 | opts: InstrumenterOptions;
|
28 |
|
29 | constructor(options?: Partial<InstrumenterOptions>);
|
30 |
|
31 | normalizeOpts(options?: Partial<InstrumenterOptions>): InstrumenterOptions;
|
32 |
|
33 | instrumentSync(
|
34 | code: string,
|
35 | filename: string,
|
36 | inputSourceMap?: RawSourceMap
|
37 | ): string;
|
38 |
|
39 | instrument(
|
40 | code: string,
|
41 | filenameOrCallback: string | InstrumenterCallback,
|
42 | callback?: InstrumenterCallback,
|
43 | inputSourceMap?: RawSourceMap
|
44 | ): void;
|
45 |
|
46 | lastFileCoverage(): FileCoverageData;
|
47 | lastSourceMap(): RawSourceMap;
|
48 | }
|
49 |
|
50 | export function createInstrumenter(
|
51 | options?: Partial<InstrumenterOptions>
|
52 | ): Instrumenter;
|
53 |
|
54 | export interface InitialCoverage {
|
55 | path: string;
|
56 | hash: string;
|
57 | gcv: any;
|
58 | coverageData: any;
|
59 | }
|
60 |
|
61 | export function readInitialCoverage(code: string): InitialCoverage;
|
62 |
|
63 | export interface Visitor {
|
64 | enter(path: string): void;
|
65 | exit(path: string): { fileCoverage: FileCoverage; sourceMappingURL: string };
|
66 | }
|
67 |
|
68 | export interface VisitorOptions {
|
69 | coverageVariable: string;
|
70 | inputSourceMap: RawSourceMap;
|
71 | }
|
72 |
|
73 | export function programVisitor(
|
74 | types: typeof babelTypes,
|
75 | sourceFilePath?: string,
|
76 | opts?: Partial<VisitorOptions>
|
77 | ): Visitor;
|