@vitest/coverage-istanbul 4.0.17 → 4.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,144 @@
1
- import libCoverage, { CoverageMap } from 'istanbul-lib-coverage';
2
- import { Instrumenter } from 'istanbul-lib-instrument';
1
+ import libCoverage, { FileCoverage, FileCoverageData, CoverageMap } from 'istanbul-lib-coverage';
3
2
  import { ProxifiedModule } from 'magicast';
4
- import { ResolvedCoverageOptions, CoverageProvider, Vitest, Vite, ReportContext } from 'vitest/node';
5
- import { BaseCoverageProvider } from 'vitest/coverage';
3
+ import { BaseCoverageProvider, ResolvedCoverageOptions, CoverageProvider, Vitest, Vite, ReportContext } from 'vitest/node';
4
+
5
+ interface GeneratorOptions {
6
+ /**
7
+ * Optional string to add as a block comment at the start of the output file.
8
+ */
9
+ auxiliaryCommentBefore?: string | undefined;
10
+
11
+ /**
12
+ * Optional string to add as a block comment at the end of the output file.
13
+ */
14
+ auxiliaryCommentAfter?: string | undefined;
15
+
16
+ /**
17
+ * Function that takes a comment (as a string) and returns true if the comment should be included in the output.
18
+ * By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment
19
+ * contains `@preserve` or `@license`.
20
+ */
21
+ shouldPrintComment?(comment: string): boolean;
22
+
23
+ /**
24
+ * Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces).
25
+ * Defaults to `false`.
26
+ */
27
+ retainLines?: boolean | undefined;
28
+
29
+ /**
30
+ * Should comments be included in output? Defaults to `true`.
31
+ */
32
+ comments?: boolean | undefined;
33
+
34
+ /**
35
+ * Set to true to avoid adding whitespace for formatting. Defaults to the value of `opts.minified`.
36
+ */
37
+ compact?: boolean | "auto" | undefined;
38
+
39
+ /**
40
+ * Should the output be minified. Defaults to `false`.
41
+ */
42
+ minified?: boolean | undefined;
43
+
44
+ /**
45
+ * Set to true to reduce whitespace (but not as much as opts.compact). Defaults to `false`.
46
+ */
47
+ concise?: boolean | undefined;
48
+
49
+ /**
50
+ * The type of quote to use in the output. If omitted, autodetects based on `ast.tokens`.
51
+ */
52
+ quotes?: "single" | "double" | undefined;
53
+
54
+ /**
55
+ * Used in warning messages
56
+ */
57
+ filename?: string | undefined;
58
+
59
+ /**
60
+ * Enable generating source maps. Defaults to `false`.
61
+ */
62
+ sourceMaps?: boolean | undefined;
63
+
64
+ /**
65
+ * The filename of the generated code that the source map will be associated with.
66
+ */
67
+ sourceMapTarget?: string | undefined;
68
+
69
+ /**
70
+ * A root for all relative URLs in the source map.
71
+ */
72
+ sourceRoot?: string | undefined;
73
+
74
+ /**
75
+ * The filename for the source code (i.e. the code in the `code` argument).
76
+ * This will only be used if `code` is a string.
77
+ */
78
+ sourceFileName?: string | undefined;
79
+
80
+ /**
81
+ * Set to true to run jsesc with "json": true to print "\u00A9" vs. "©";
82
+ */
83
+ jsonCompatibleStrings?: boolean | undefined;
84
+ }
85
+
86
+ interface StartOfSourceMap {
87
+ file?: string;
88
+ sourceRoot?: string;
89
+ }
90
+
91
+ interface RawSourceMap extends StartOfSourceMap {
92
+ version: string;
93
+ sources: string[];
94
+ names: string[];
95
+ sourcesContent?: string[];
96
+ mappings: string;
97
+ }
98
+
99
+ interface InstrumenterOptions {
100
+ coverageVariable: string;
101
+ preserveComments: boolean;
102
+ compact: boolean;
103
+ esModules: boolean;
104
+ autoWrap: boolean;
105
+ produceSourceMap: boolean;
106
+ sourceMapUrlCallback(filename: string, url: string): void;
107
+ debug: boolean;
108
+ coverageGlobalScope?: string;
109
+ coverageGlobalScopeFunc?: boolean;
110
+ ignoreClassMethods?: string[];
111
+ parserPlugins?: any[];
112
+ generatorOpts?: GeneratorOptions;
113
+ }
114
+
115
+ type InstrumenterCallback = (error: Error | null, code: string) => void;
116
+
117
+ declare class Instrumenter {
118
+ fileCoverage: FileCoverage;
119
+ sourceMap: RawSourceMap | null;
120
+ opts: InstrumenterOptions;
121
+
122
+ constructor(options?: Partial<InstrumenterOptions>);
123
+
124
+ normalizeOpts(options?: Partial<InstrumenterOptions>): InstrumenterOptions;
125
+
126
+ instrumentSync(
127
+ code: string,
128
+ filename: string,
129
+ inputSourceMap?: RawSourceMap,
130
+ ): string;
131
+
132
+ instrument(
133
+ code: string,
134
+ filenameOrCallback: string | InstrumenterCallback,
135
+ callback?: InstrumenterCallback,
136
+ inputSourceMap?: RawSourceMap,
137
+ ): void;
138
+
139
+ lastFileCoverage(): FileCoverageData;
140
+ lastSourceMap(): RawSourceMap;
141
+ }
6
142
 
7
143
  declare class IstanbulCoverageProvider extends BaseCoverageProvider<ResolvedCoverageOptions<"istanbul">> implements CoverageProvider {
8
144
  name: "istanbul";