forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma-coverage-tests.ts
220 lines (200 loc) · 5.58 KB
/
karma-coverage-tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/// <reference path="karma-coverage.d.ts" />
import * as karma from 'karma-coverage';
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#basic
module.exports = function(config: karma.Config) {
config.set({
files: [
'src/**/*.js',
'test/**/*.js'
],
// coverage reporter generates the coverage
reporters: ['progress', 'coverage'],
preprocessors: {
// source files, that you wanna generate coverage for
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
'src/**/*.js': ['coverage']
},
// optionally, configure the reporter
coverageReporter: {
type : 'html',
dir : 'coverage/'
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#advanced-multiple-reporters
module.exports = function(config: karma.Config) {
config.set({
files: [
'src/**/*.js',
'test/**/*.js'
],
reporters: ['progress', 'coverage'],
preprocessors: {
'src/**/*.js': ['coverage']
},
coverageReporter: {
// specify a common output directory
dir: 'build/reports/coverage',
reporters: [
// reporters not supporting the `file` property
{ type: 'html', subdir: 'report-html' },
{ type: 'lcov', subdir: 'report-lcov' },
// reporters supporting the `file` property, use `subdir` to directly
// output them in the `dir` directory
{ type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
{ type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
{ type: 'teamcity', subdir: '.', file: 'teamcity.txt' },
{ type: 'text', subdir: '.', file: 'text.txt' },
{ type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
]
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#dont-minify-instrumenter-output
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
instrumenterOptions: {
istanbul: { noCompact: true }
}
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#subdir
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
dir: 'coverage',
subdir: '.'
// Would output the results into: .'/coverage/'
}
});
};
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
dir: 'coverage',
subdir: 'report'
// Would output the results into: .'/coverage/report/'
}
});
};
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
dir: 'coverage',
subdir: function(browser) {
// normalization process to keep a consistent browser name accross different
// OS
return browser.toLowerCase().split(/[ /-]/)[0];
}
// Would output the results into: './coverage/firefox/'
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#file
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
type : 'text',
dir : 'coverage/',
file : 'coverage.txt'
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#check
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
check: {
global: {
statements: 50,
branches: 50,
functions: 50,
lines: 50,
excludes: [
'foo/bar/**/*.js'
]
},
each: {
statements: 50,
branches: 50,
functions: 50,
lines: 50,
excludes: [
'other/directory/**/*.js'
],
overrides: {
'baz/component/**/*.js': {
statements: 98
}
}
}
}
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#watermarks
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
watermarks: {
statements: [ 50, 75 ],
functions: [ 50, 75 ],
branches: [ 50, 75 ],
lines: [ 50, 75 ]
}
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#sourcestore
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
type : 'text',
dir : 'coverage/',
file : 'coverage.txt',
sourceStore : require('istanbul').Store.create('fslookup')
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#reporters
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
reporters:[
{type: 'html', dir:'coverage/'},
{type: 'teamcity'},
{type: 'text-summary'}
],
}
});
};
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#instrumenter
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
instrumenters: { ibrik : require('ibrik') },
instrumenter: {
'**/*.coffee': 'ibrik'
},
// ...
}
});
};
var to5Options = { experimental: true };
// [...]
module.exports = function(config: karma.Config) {
config.set({
coverageReporter: {
instrumenters: { isparta : require('isparta') },
instrumenter: {
'**/*.js': 'isparta'
},
instrumenterOptions: {
isparta: { to5 : to5Options }
}
}
});
};