@vitest/coverage-istanbul 0.29.6 → 0.29.8

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.
@@ -0,0 +1,3 @@
1
+ const COVERAGE_STORE_KEY = "__VITEST_COVERAGE__";
2
+
3
+ export { COVERAGE_STORE_KEY as C };
package/dist/index.d.ts CHANGED
@@ -1,234 +1,14 @@
1
- import { CoverageProvider, Vitest, AfterSuiteRunMeta, ReportContext, ResolvedCoverageOptions } from 'vitest';
2
- import { BaseCoverageProvider } from 'vitest/coverage';
3
- import { CoverageMap } from 'istanbul-lib-coverage';
4
- import { Instrumenter } from 'istanbul-lib-instrument';
5
-
6
- interface RollupError extends RollupLogProps {
7
- parserError?: Error;
8
- stack?: string;
9
- watchFiles?: string[];
10
- }
11
-
12
- interface RollupWarning extends RollupLogProps {
13
- chunkName?: string;
14
- cycle?: string[];
15
- exportName?: string;
16
- exporter?: string;
17
- guess?: string;
18
- importer?: string;
19
- missing?: string;
20
- modules?: string[];
21
- names?: string[];
22
- reexporter?: string;
23
- source?: string;
24
- sources?: string[];
25
- }
26
-
27
- interface RollupLogProps {
28
- code?: string;
29
- frame?: string;
30
- hook?: string;
31
- id?: string;
32
- loc?: {
33
- column: number;
34
- file?: string;
35
- line: number;
36
- };
37
- message: string;
38
- name?: string;
39
- plugin?: string;
40
- pluginCode?: string;
41
- pos?: number;
42
- url?: string;
43
- }
44
-
45
- interface SourceMap {
46
- file: string;
47
- mappings: string;
48
- names: string[];
49
- sources: string[];
50
- sourcesContent: string[];
51
- version: number;
52
- toString(): string;
53
- toUrl(): string;
54
- }
55
-
56
- type PartialNull<T> = {
57
- [P in keyof T]: T[P] | null;
58
- };
59
-
60
- interface ModuleOptions {
61
- meta: CustomPluginOptions;
62
- moduleSideEffects: boolean | 'no-treeshake';
63
- syntheticNamedExports: boolean | string;
64
- }
65
-
66
- interface PluginCache {
67
- delete(id: string): boolean;
68
- get<T = any>(id: string): T;
69
- has(id: string): boolean;
70
- set<T = any>(id: string, value: T): void;
71
- }
72
-
73
- interface MinimalPluginContext {
74
- meta: PluginContextMeta;
75
- }
76
-
77
- interface EmittedAsset {
78
- fileName?: string;
79
- name?: string;
80
- source?: string | Uint8Array;
81
- type: 'asset';
82
- }
83
-
84
- interface EmittedChunk {
85
- fileName?: string;
86
- id: string;
87
- implicitlyLoadedAfterOneOf?: string[];
88
- importer?: string;
89
- name?: string;
90
- preserveSignature?: PreserveEntrySignaturesOption;
91
- type: 'chunk';
92
- }
93
-
94
- type EmittedFile = EmittedAsset | EmittedChunk;
95
-
96
- type EmitAsset = (name: string, source?: string | Uint8Array) => string;
97
-
98
- type EmitChunk = (id: string, options?: { name?: string }) => string;
99
-
100
- type EmitFile = (emittedFile: EmittedFile) => string;
101
-
102
- interface ModuleInfo extends ModuleOptions {
103
- ast: AcornNode | null;
104
- code: string | null;
105
- dynamicImporters: readonly string[];
106
- dynamicallyImportedIdResolutions: readonly ResolvedId[];
107
- dynamicallyImportedIds: readonly string[];
108
- hasDefaultExport: boolean | null;
109
- /** @deprecated Use `moduleSideEffects` instead */
110
- hasModuleSideEffects: boolean | 'no-treeshake';
111
- id: string;
112
- implicitlyLoadedAfterOneOf: readonly string[];
113
- implicitlyLoadedBefore: readonly string[];
114
- importedIdResolutions: readonly ResolvedId[];
115
- importedIds: readonly string[];
116
- importers: readonly string[];
117
- isEntry: boolean;
118
- isExternal: boolean;
119
- isIncluded: boolean | null;
120
- }
121
-
122
- type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
123
-
124
- interface CustomPluginOptions {
125
- [plugin: string]: any;
126
- }
127
-
128
- interface PluginContext extends MinimalPluginContext {
129
- addWatchFile: (id: string) => void;
130
- cache: PluginCache;
131
- /** @deprecated Use `this.emitFile` instead */
132
- emitAsset: EmitAsset;
133
- /** @deprecated Use `this.emitFile` instead */
134
- emitChunk: EmitChunk;
135
- emitFile: EmitFile;
136
- error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
137
- /** @deprecated Use `this.getFileName` instead */
138
- getAssetFileName: (assetReferenceId: string) => string;
139
- /** @deprecated Use `this.getFileName` instead */
140
- getChunkFileName: (chunkReferenceId: string) => string;
141
- getFileName: (fileReferenceId: string) => string;
142
- getModuleIds: () => IterableIterator<string>;
143
- getModuleInfo: GetModuleInfo;
144
- getWatchFiles: () => string[];
145
- /** @deprecated Use `this.resolve` instead */
146
- isExternal: IsExternal;
147
- load: (
148
- options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
149
- ) => Promise<ModuleInfo>;
150
- /** @deprecated Use `this.getModuleIds` instead */
151
- moduleIds: IterableIterator<string>;
152
- parse: (input: string, options?: any) => AcornNode;
153
- resolve: (
154
- source: string,
155
- importer?: string,
156
- options?: { custom?: CustomPluginOptions; isEntry?: boolean; skipSelf?: boolean }
157
- ) => Promise<ResolvedId | null>;
158
- /** @deprecated Use `this.resolve` instead */
159
- resolveId: (source: string, importer?: string) => Promise<string | null>;
160
- setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
161
- warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
162
- }
163
-
164
- interface PluginContextMeta {
165
- rollupVersion: string;
166
- watchMode: boolean;
167
- }
168
-
169
- interface ResolvedId extends ModuleOptions {
170
- external: boolean | 'absolute';
171
- id: string;
172
- }
173
-
174
- type IsExternal = (
175
- source: string,
176
- importer: string | undefined,
177
- isResolved: boolean
178
- ) => boolean;
179
-
180
- interface TransformPluginContext extends PluginContext {
181
- getCombinedSourcemap: () => SourceMap;
182
- }
183
- type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
184
-
185
- interface AcornNode {
186
- end: number;
187
- start: number;
188
- type: string;
189
- }
190
-
191
- type Options = ResolvedCoverageOptions<'istanbul'>;
192
- type Threshold = 'lines' | 'functions' | 'statements' | 'branches';
193
- interface TestExclude {
194
- new (opts: {
195
- cwd?: string | string[];
196
- include?: string | string[];
197
- exclude?: string | string[];
198
- extension?: string | string[];
199
- excludeNodeModules?: boolean;
200
- }): {
201
- shouldInstrument(filePath: string): boolean;
202
- glob(cwd: string): Promise<string[]>;
203
- };
204
- }
205
- declare class IstanbulCoverageProvider extends BaseCoverageProvider implements CoverageProvider {
206
- name: string;
207
- ctx: Vitest;
208
- options: Options;
209
- instrumenter: Instrumenter;
210
- testExclude: InstanceType<TestExclude>;
211
- /**
212
- * Coverage objects collected from workers.
213
- * Some istanbul utilizers write these into file system instead of storing in memory.
214
- * If storing in memory causes issues, we can simply write these into fs in `onAfterSuiteRun`
215
- * and read them back when merging coverage objects in `onAfterAllFilesRun`.
216
- */
217
- coverages: any[];
218
- initialize(ctx: Vitest): void;
219
- resolveOptions(): Options;
220
- onFileTransform(sourceCode: string, id: string, pluginCtx: TransformPluginContext): {
221
- code: string;
222
- map: any;
223
- } | undefined;
224
- onAfterSuiteRun({ coverage }: AfterSuiteRunMeta): void;
225
- clean(clean?: boolean): Promise<void>;
226
- reportCoverage({ allTestsRun }?: ReportContext): Promise<void>;
227
- checkThresholds(coverageMap: CoverageMap, thresholds: Record<Threshold, number | undefined>): void;
228
- includeUntestedFiles(coverageMap: CoverageMap): Promise<void>;
229
- }
1
+ import { IstanbulCoverageProvider } from './provider.js';
2
+ import 'vitest';
3
+ import 'vitest/coverage';
4
+ import 'istanbul-lib-coverage';
5
+ import 'istanbul-lib-instrument';
230
6
 
231
7
  declare function getProvider(): Promise<IstanbulCoverageProvider>;
232
8
  declare function takeCoverage(): any;
9
+ declare const _default: {
10
+ getProvider: typeof getProvider;
11
+ takeCoverage: typeof takeCoverage;
12
+ };
233
13
 
234
- export { getProvider, takeCoverage };
14
+ export { _default as default, getProvider, takeCoverage };
package/dist/index.js CHANGED
@@ -1 +1,18 @@
1
- export { g as getProvider, t as takeCoverage } from './index-f1f55bac.js';
1
+ import { C as COVERAGE_STORE_KEY } from './constants-65b08378.js';
2
+
3
+ async function getProvider() {
4
+ const providerPath = "./provider.js";
5
+ const { IstanbulCoverageProvider } = await import(providerPath);
6
+ return new IstanbulCoverageProvider();
7
+ }
8
+ function takeCoverage() {
9
+ const coverage = globalThis[COVERAGE_STORE_KEY];
10
+ globalThis[COVERAGE_STORE_KEY] = {};
11
+ return coverage;
12
+ }
13
+ var index = {
14
+ getProvider,
15
+ takeCoverage
16
+ };
17
+
18
+ export { index as default, getProvider, takeCoverage };
@@ -0,0 +1,231 @@
1
+ import { CoverageProvider, Vitest, AfterSuiteRunMeta, ReportContext, ResolvedCoverageOptions } from 'vitest';
2
+ import { BaseCoverageProvider } from 'vitest/coverage';
3
+ import { CoverageMap } from 'istanbul-lib-coverage';
4
+ import { Instrumenter } from 'istanbul-lib-instrument';
5
+
6
+ interface RollupError extends RollupLogProps {
7
+ parserError?: Error;
8
+ stack?: string;
9
+ watchFiles?: string[];
10
+ }
11
+
12
+ interface RollupWarning extends RollupLogProps {
13
+ chunkName?: string;
14
+ cycle?: string[];
15
+ exportName?: string;
16
+ exporter?: string;
17
+ guess?: string;
18
+ importer?: string;
19
+ missing?: string;
20
+ modules?: string[];
21
+ names?: string[];
22
+ reexporter?: string;
23
+ source?: string;
24
+ sources?: string[];
25
+ }
26
+
27
+ interface RollupLogProps {
28
+ code?: string;
29
+ frame?: string;
30
+ hook?: string;
31
+ id?: string;
32
+ loc?: {
33
+ column: number;
34
+ file?: string;
35
+ line: number;
36
+ };
37
+ message: string;
38
+ name?: string;
39
+ plugin?: string;
40
+ pluginCode?: string;
41
+ pos?: number;
42
+ url?: string;
43
+ }
44
+
45
+ interface SourceMap {
46
+ file: string;
47
+ mappings: string;
48
+ names: string[];
49
+ sources: string[];
50
+ sourcesContent: string[];
51
+ version: number;
52
+ toString(): string;
53
+ toUrl(): string;
54
+ }
55
+
56
+ type PartialNull<T> = {
57
+ [P in keyof T]: T[P] | null;
58
+ };
59
+
60
+ interface ModuleOptions {
61
+ meta: CustomPluginOptions;
62
+ moduleSideEffects: boolean | 'no-treeshake';
63
+ syntheticNamedExports: boolean | string;
64
+ }
65
+
66
+ interface PluginCache {
67
+ delete(id: string): boolean;
68
+ get<T = any>(id: string): T;
69
+ has(id: string): boolean;
70
+ set<T = any>(id: string, value: T): void;
71
+ }
72
+
73
+ interface MinimalPluginContext {
74
+ meta: PluginContextMeta;
75
+ }
76
+
77
+ interface EmittedAsset {
78
+ fileName?: string;
79
+ name?: string;
80
+ source?: string | Uint8Array;
81
+ type: 'asset';
82
+ }
83
+
84
+ interface EmittedChunk {
85
+ fileName?: string;
86
+ id: string;
87
+ implicitlyLoadedAfterOneOf?: string[];
88
+ importer?: string;
89
+ name?: string;
90
+ preserveSignature?: PreserveEntrySignaturesOption;
91
+ type: 'chunk';
92
+ }
93
+
94
+ type EmittedFile = EmittedAsset | EmittedChunk;
95
+
96
+ type EmitAsset = (name: string, source?: string | Uint8Array) => string;
97
+
98
+ type EmitChunk = (id: string, options?: { name?: string }) => string;
99
+
100
+ type EmitFile = (emittedFile: EmittedFile) => string;
101
+
102
+ interface ModuleInfo extends ModuleOptions {
103
+ ast: AcornNode | null;
104
+ code: string | null;
105
+ dynamicImporters: readonly string[];
106
+ dynamicallyImportedIdResolutions: readonly ResolvedId[];
107
+ dynamicallyImportedIds: readonly string[];
108
+ hasDefaultExport: boolean | null;
109
+ /** @deprecated Use `moduleSideEffects` instead */
110
+ hasModuleSideEffects: boolean | 'no-treeshake';
111
+ id: string;
112
+ implicitlyLoadedAfterOneOf: readonly string[];
113
+ implicitlyLoadedBefore: readonly string[];
114
+ importedIdResolutions: readonly ResolvedId[];
115
+ importedIds: readonly string[];
116
+ importers: readonly string[];
117
+ isEntry: boolean;
118
+ isExternal: boolean;
119
+ isIncluded: boolean | null;
120
+ }
121
+
122
+ type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
123
+
124
+ interface CustomPluginOptions {
125
+ [plugin: string]: any;
126
+ }
127
+
128
+ interface PluginContext extends MinimalPluginContext {
129
+ addWatchFile: (id: string) => void;
130
+ cache: PluginCache;
131
+ /** @deprecated Use `this.emitFile` instead */
132
+ emitAsset: EmitAsset;
133
+ /** @deprecated Use `this.emitFile` instead */
134
+ emitChunk: EmitChunk;
135
+ emitFile: EmitFile;
136
+ error: (err: RollupError | string, pos?: number | { column: number; line: number }) => never;
137
+ /** @deprecated Use `this.getFileName` instead */
138
+ getAssetFileName: (assetReferenceId: string) => string;
139
+ /** @deprecated Use `this.getFileName` instead */
140
+ getChunkFileName: (chunkReferenceId: string) => string;
141
+ getFileName: (fileReferenceId: string) => string;
142
+ getModuleIds: () => IterableIterator<string>;
143
+ getModuleInfo: GetModuleInfo;
144
+ getWatchFiles: () => string[];
145
+ /** @deprecated Use `this.resolve` instead */
146
+ isExternal: IsExternal;
147
+ load: (
148
+ options: { id: string; resolveDependencies?: boolean } & Partial<PartialNull<ModuleOptions>>
149
+ ) => Promise<ModuleInfo>;
150
+ /** @deprecated Use `this.getModuleIds` instead */
151
+ moduleIds: IterableIterator<string>;
152
+ parse: (input: string, options?: any) => AcornNode;
153
+ resolve: (
154
+ source: string,
155
+ importer?: string,
156
+ options?: { custom?: CustomPluginOptions; isEntry?: boolean; skipSelf?: boolean }
157
+ ) => Promise<ResolvedId | null>;
158
+ /** @deprecated Use `this.resolve` instead */
159
+ resolveId: (source: string, importer?: string) => Promise<string | null>;
160
+ setAssetSource: (assetReferenceId: string, source: string | Uint8Array) => void;
161
+ warn: (warning: RollupWarning | string, pos?: number | { column: number; line: number }) => void;
162
+ }
163
+
164
+ interface PluginContextMeta {
165
+ rollupVersion: string;
166
+ watchMode: boolean;
167
+ }
168
+
169
+ interface ResolvedId extends ModuleOptions {
170
+ external: boolean | 'absolute';
171
+ id: string;
172
+ }
173
+
174
+ type IsExternal = (
175
+ source: string,
176
+ importer: string | undefined,
177
+ isResolved: boolean
178
+ ) => boolean;
179
+
180
+ interface TransformPluginContext extends PluginContext {
181
+ getCombinedSourcemap: () => SourceMap;
182
+ }
183
+ type PreserveEntrySignaturesOption = false | 'strict' | 'allow-extension' | 'exports-only';
184
+
185
+ interface AcornNode {
186
+ end: number;
187
+ start: number;
188
+ type: string;
189
+ }
190
+
191
+ type Options = ResolvedCoverageOptions<'istanbul'>;
192
+ type Threshold = 'lines' | 'functions' | 'statements' | 'branches';
193
+ interface TestExclude {
194
+ new (opts: {
195
+ cwd?: string | string[];
196
+ include?: string | string[];
197
+ exclude?: string | string[];
198
+ extension?: string | string[];
199
+ excludeNodeModules?: boolean;
200
+ }): {
201
+ shouldInstrument(filePath: string): boolean;
202
+ glob(cwd: string): Promise<string[]>;
203
+ };
204
+ }
205
+ declare class IstanbulCoverageProvider extends BaseCoverageProvider implements CoverageProvider {
206
+ name: string;
207
+ ctx: Vitest;
208
+ options: Options;
209
+ instrumenter: Instrumenter;
210
+ testExclude: InstanceType<TestExclude>;
211
+ /**
212
+ * Coverage objects collected from workers.
213
+ * Some istanbul utilizers write these into file system instead of storing in memory.
214
+ * If storing in memory causes issues, we can simply write these into fs in `onAfterSuiteRun`
215
+ * and read them back when merging coverage objects in `onAfterAllFilesRun`.
216
+ */
217
+ coverages: any[];
218
+ initialize(ctx: Vitest): void;
219
+ resolveOptions(): Options;
220
+ onFileTransform(sourceCode: string, id: string, pluginCtx: TransformPluginContext): {
221
+ code: string;
222
+ map: any;
223
+ } | undefined;
224
+ onAfterSuiteRun({ coverage }: AfterSuiteRunMeta): void;
225
+ clean(clean?: boolean): Promise<void>;
226
+ reportCoverage({ allTestsRun }?: ReportContext): Promise<void>;
227
+ checkThresholds(coverageMap: CoverageMap, thresholds: Record<Threshold, number | undefined>): void;
228
+ includeUntestedFiles(coverageMap: CoverageMap): Promise<void>;
229
+ }
230
+
231
+ export { IstanbulCoverageProvider };
@@ -7,7 +7,7 @@ import libCoverage from 'istanbul-lib-coverage';
7
7
  import libSourceMaps from 'istanbul-lib-source-maps';
8
8
  import { createInstrumenter } from 'istanbul-lib-instrument';
9
9
  import _TestExclude from 'test-exclude';
10
- import { C as COVERAGE_STORE_KEY } from './index-f1f55bac.js';
10
+ import { C as COVERAGE_STORE_KEY } from './constants-65b08378.js';
11
11
 
12
12
  function normalizeWindowsPath(input = "") {
13
13
  if (!input || !input.includes("\\")) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/coverage-istanbul",
3
3
  "type": "module",
4
- "version": "0.29.6",
4
+ "version": "0.29.8",
5
5
  "description": "Istanbul coverage provider for Vitest",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  "@types/istanbul-lib-source-maps": "^4.0.1",
55
55
  "@types/istanbul-reports": "^3.0.1",
56
56
  "pathe": "^1.1.0",
57
- "vitest": "0.29.6"
57
+ "vitest": "0.29.8"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "rimraf dist && rollup -c",
@@ -1,13 +0,0 @@
1
- const COVERAGE_STORE_KEY = "__VITEST_COVERAGE__";
2
-
3
- async function getProvider() {
4
- const { IstanbulCoverageProvider } = await import('./provider-bca6bd2d.js');
5
- return new IstanbulCoverageProvider();
6
- }
7
- function takeCoverage() {
8
- const coverage = globalThis[COVERAGE_STORE_KEY];
9
- globalThis[COVERAGE_STORE_KEY] = {};
10
- return coverage;
11
- }
12
-
13
- export { COVERAGE_STORE_KEY as C, getProvider as g, takeCoverage as t };