UNPKG

2.83 kBTypeScriptView Raw
1export interface Threshold {
2 /** @default 0 */
3 readonly statements?: number | undefined;
4
5 /** @default 0 */
6 readonly lines?: number | undefined;
7
8 /** @default 0 */
9 readonly branches?: number | undefined;
10
11 /** @default 0 */
12 readonly functions?: number | undefined;
13}
14
15export interface ThresholdsEach extends Threshold {
16 /** @default {} */
17 readonly overrides?: { [key: string]: Threshold } | undefined;
18}
19
20export interface ThresholdConfig {
21 /**
22 * Set to `true` to not fail the test command when thresholds are not met.
23 * @default false
24 */
25 readonly emitWarning?: boolean | undefined;
26
27 /** Thresholds for all files. */
28 readonly global?: Threshold | undefined;
29
30 /** Thresholds per file. */
31 readonly each?: ThresholdsEach | undefined;
32}
33
34/** @see {@link https://github.com/mattlewis92/karma-coverage-istanbul-reporter#configuration} */
35export interface CoverageIstanbulReporter {
36 /** Reports can be any that are listed {@link https://github.com/istanbuljs/istanbuljs/tree/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib here}. */
37 readonly reports?: string[] | undefined;
38
39 /**
40 * Base output directory.
41 * If you include `%browser%` in the path it will be replaced with the karma browser name.
42 */
43 readonly dir?: string | undefined;
44
45 /** Combines coverage information from multiple browsers into one report rather than outputting a report for each browser */
46 readonly combineBrowserReports?: boolean | undefined;
47
48 /** if using webpack and pre-loaders, work around webpack breaking the source path. */
49 readonly fixWebpackSourcePaths?: boolean | undefined;
50
51 /** Omit files with no statements, no functions and no branches from the report. */
52 readonly skipFilesWithNoCoverage?: boolean | undefined;
53
54 // TODO: Add istanbul-api
55 /** Most reporters accept additional config options. You can pass these through the `report-config` option. */
56 readonly "report-config"?: any;
57
58 /**
59 * Enforce percentage thresholds.
60 * Anything under these percentages will cause karma to fail with an exit code of 1 if not running in watch mode.
61 */
62 readonly thresholds?: ThresholdConfig | undefined;
63
64 /** Output config used by istanbul for debugging. */
65 readonly verbose?: boolean | undefined;
66
67 // TODO: Add istanbul-api
68 /** `instrumentation` is used to configure Istanbul API package. */
69 readonly instrumentation?: any;
70}
71
72declare module "karma" {
73 interface ConfigOptions {
74 /** {@link https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-api/lib/config.js#L33-L39 Any of these options are valid}. */
75 readonly coverageIstanbulReporter?: CoverageIstanbulReporter | undefined;
76 }
77}