Skip to content

Commit bc347a9

Browse files
elliottsjBenjamin E. Coe
andauthored
feat: support passing reporter options (#423)
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
1 parent b93b9c0 commit bc347a9

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

lib/report.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Report {
1919
excludeAfterRemap,
2020
include,
2121
reporter,
22+
reporterOptions,
2223
reportsDirectory,
2324
tempDirectory,
2425
watermarks,
@@ -32,6 +33,7 @@ class Report {
3233
excludeNodeModules
3334
}) {
3435
this.reporter = reporter
36+
this.reporterOptions = reporterOptions || {}
3537
this.reportsDirectory = reportsDirectory
3638
this.tempDirectory = tempDirectory
3739
this.watermarks = watermarks
@@ -74,7 +76,8 @@ class Report {
7476
reports.create(_reporter, {
7577
skipEmpty: false,
7678
skipFull: this.skipFull,
77-
maxCols: process.stdout.columns || 100
79+
maxCols: process.stdout.columns || 100,
80+
...this.reporterOptions[_reporter]
7881
}).execute(context)
7982
}
8083
}

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/integration.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ All files | 1.91 | 12 | 6.25 | 1.91
168168
c8/lib | 0 | 0 | 0 | 0 |
169169
is-cjs-esm-bridge.js | 0 | 0 | 0 | 0 | 1-10
170170
parse-args.js | 0 | 0 | 0 | 0 | 1-218
171-
report.js | 0 | 0 | 0 | 0 | 1-337
171+
report.js | 0 | 0 | 0 | 0 | 1-340
172172
source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100
173173
c8/lib/commands | 0 | 0 | 0 | 0 |
174174
check-coverage.js | 0 | 0 | 0 | 0 | 1-70

test/integration.js_10.snap

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ All files | 1.91 | 12 | 8.16 | 1.91
168168
c8/lib | 0 | 0 | 0 | 0 |
169169
is-cjs-esm-bridge.js | 0 | 0 | 0 | 0 | 1-10
170170
parse-args.js | 0 | 0 | 0 | 0 | 1-218
171-
report.js | 0 | 0 | 0 | 0 | 1-337
171+
report.js | 0 | 0 | 0 | 0 | 1-340
172172
source-map-from-file.js | 0 | 0 | 0 | 0 | 1-100
173173
c8/lib/commands | 0 | 0 | 0 | 0 |
174174
check-coverage.js | 0 | 0 | 0 | 0 | 1-70
@@ -257,13 +257,13 @@ hey
257257
--------------------------|---------|----------|---------|---------|--------------------------------
258258
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
259259
--------------------------|---------|----------|---------|---------|--------------------------------
260-
All files | 73.95 | 58.82 | 63.41 | 73.95 |
260+
All files | 74.04 | 58.82 | 63.41 | 74.04 |
261261
bin | 78.84 | 60 | 66.66 | 78.84 |
262262
c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51
263-
lib | 78.49 | 54.23 | 73.07 | 78.49 |
263+
lib | 78.59 | 54.23 | 73.07 | 78.59 |
264264
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
265265
parse-args.js | 97.24 | 58.33 | 100 | 97.24 | 159-160,181-182,195-196
266-
report.js | 75.96 | 57.89 | 80 | 75.96 | ...281,287-289,310-315,326-327
266+
report.js | 76.17 | 57.89 | 80 | 76.17 | ...284,290-292,313-318,329-330
267267
source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98
268268
lib/commands | 41.44 | 66.66 | 16.66 | 41.44 |
269269
check-coverage.js | 18.57 | 100 | 0 | 18.57 | 9-11,14-36,39-53,55-70
@@ -272,9 +272,9 @@ All files | 73.95 | 58.82 | 63.41 | 73.95 |
272272
async.js | 100 | 100 | 100 | 100 |
273273
normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20
274274
--------------------------|---------|----------|---------|---------|--------------------------------
275-
,ERROR: Coverage for lines (73.95%) does not meet global threshold (101%)
275+
,ERROR: Coverage for lines (74.04%) does not meet global threshold (101%)
276276
ERROR: Coverage for branches (58.82%) does not meet global threshold (82%)
277-
ERROR: Coverage for statements (73.95%) does not meet global threshold (95%)
277+
ERROR: Coverage for statements (74.04%) does not meet global threshold (95%)
278278
"
279279
`;
280280

@@ -292,9 +292,9 @@ ERROR: Coverage for branches (25%) does not meet threshold (82%) for lib/is-cjs-
292292
ERROR: Coverage for statements (90%) does not meet threshold (95%) for lib/is-cjs-esm-bridge.js
293293
ERROR: Coverage for lines (97.24%) does not meet threshold (101%) for lib/parse-args.js
294294
ERROR: Coverage for branches (58.33%) does not meet threshold (82%) for lib/parse-args.js
295-
ERROR: Coverage for lines (75.96%) does not meet threshold (101%) for lib/report.js
295+
ERROR: Coverage for lines (76.17%) does not meet threshold (101%) for lib/report.js
296296
ERROR: Coverage for branches (57.89%) does not meet threshold (82%) for lib/report.js
297-
ERROR: Coverage for statements (75.96%) does not meet threshold (95%) for lib/report.js
297+
ERROR: Coverage for statements (76.17%) does not meet threshold (95%) for lib/report.js
298298
ERROR: Coverage for lines (45%) does not meet threshold (101%) for lib/source-map-from-file.js
299299
ERROR: Coverage for statements (45%) does not meet threshold (95%) for lib/source-map-from-file.js
300300
ERROR: Coverage for lines (100%) does not meet threshold (101%) for test/fixtures/async.js
@@ -305,19 +305,19 @@ ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixt
305305
`;
306306

307307
exports[`c8 check-coverage check-coverage command with --100 1`] = `
308-
",,ERROR: Coverage for lines (77.66%) does not meet global threshold (100%)
308+
",,ERROR: Coverage for lines (77.73%) does not meet global threshold (100%)
309309
ERROR: Coverage for functions (67.44%) does not meet global threshold (100%)
310310
ERROR: Coverage for branches (62.06%) does not meet global threshold (100%)
311-
ERROR: Coverage for statements (77.66%) does not meet global threshold (100%)
311+
ERROR: Coverage for statements (77.73%) does not meet global threshold (100%)
312312
"
313313
`;
314314

315315
exports[`c8 check-coverage exits with 0 if coverage within threshold 1`] = `",,"`;
316316

317317
exports[`c8 check-coverage exits with 1 if coverage is below threshold 1`] = `
318-
",,ERROR: Coverage for lines (73.95%) does not meet global threshold (101%)
318+
",,ERROR: Coverage for lines (74.04%) does not meet global threshold (101%)
319319
ERROR: Coverage for branches (58.82%) does not meet global threshold (82%)
320-
ERROR: Coverage for statements (73.95%) does not meet global threshold (95%)
320+
ERROR: Coverage for statements (74.04%) does not meet global threshold (95%)
321321
"
322322
`;
323323

@@ -404,13 +404,13 @@ exports[`c8 report generates report from existing temporary files 1`] = `
404404
",--------------------------|---------|----------|---------|---------|--------------------------------
405405
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
406406
--------------------------|---------|----------|---------|---------|--------------------------------
407-
All files | 73.95 | 58.82 | 63.41 | 73.95 |
407+
All files | 74.04 | 58.82 | 63.41 | 74.04 |
408408
bin | 78.84 | 60 | 66.66 | 78.84 |
409409
c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51
410-
lib | 78.49 | 54.23 | 73.07 | 78.49 |
410+
lib | 78.59 | 54.23 | 73.07 | 78.59 |
411411
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
412412
parse-args.js | 97.24 | 58.33 | 100 | 97.24 | 159-160,181-182,195-196
413-
report.js | 75.96 | 57.89 | 80 | 75.96 | ...281,287-289,310-315,326-327
413+
report.js | 76.17 | 57.89 | 80 | 76.17 | ...284,290-292,313-318,329-330
414414
source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98
415415
lib/commands | 41.44 | 66.66 | 16.66 | 41.44 |
416416
check-coverage.js | 18.57 | 100 | 0 | 18.57 | 9-11,14-36,39-53,55-70
@@ -426,13 +426,13 @@ exports[`c8 report supports --check-coverage, when generating reports 1`] = `
426426
",--------------------------|---------|----------|---------|---------|--------------------------------
427427
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
428428
--------------------------|---------|----------|---------|---------|--------------------------------
429-
All files | 73.95 | 58.82 | 63.41 | 73.95 |
429+
All files | 74.04 | 58.82 | 63.41 | 74.04 |
430430
bin | 78.84 | 60 | 66.66 | 78.84 |
431431
c8.js | 78.84 | 60 | 66.66 | 78.84 | 22,27-29,32-33,41-43,50-51
432-
lib | 78.49 | 54.23 | 73.07 | 78.49 |
432+
lib | 78.59 | 54.23 | 73.07 | 78.59 |
433433
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
434434
parse-args.js | 97.24 | 58.33 | 100 | 97.24 | 159-160,181-182,195-196
435-
report.js | 75.96 | 57.89 | 80 | 75.96 | ...281,287-289,310-315,326-327
435+
report.js | 76.17 | 57.89 | 80 | 76.17 | ...284,290-292,313-318,329-330
436436
source-map-from-file.js | 45 | 100 | 0 | 45 | 39-50,52-67,69-77,81-98
437437
lib/commands | 41.44 | 66.66 | 16.66 | 41.44 |
438438
check-coverage.js | 18.57 | 100 | 0 | 18.57 | 9-11,14-36,39-53,55-70
@@ -441,9 +441,9 @@ All files | 73.95 | 58.82 | 63.41 | 73.95 |
441441
async.js | 100 | 100 | 100 | 100 |
442442
normal.js | 75 | 66.66 | 33.33 | 75 | 14-16,18-20
443443
--------------------------|---------|----------|---------|---------|--------------------------------
444-
,ERROR: Coverage for lines (73.95%) does not meet global threshold (101%)
444+
,ERROR: Coverage for lines (74.04%) does not meet global threshold (101%)
445445
ERROR: Coverage for branches (58.82%) does not meet global threshold (82%)
446-
ERROR: Coverage for statements (73.95%) does not meet global threshold (95%)
446+
ERROR: Coverage for statements (74.04%) does not meet global threshold (95%)
447447
"
448448
`;
449449

0 commit comments

Comments
 (0)