source: trip-planner-front/node_modules/karma-coverage/lib/report-creator.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 837 bytes
Line 
1// Report Creator
2// ==============
3//
4// Wrapper of Istanbul's report creator to allow registering
5// custom reporters
6
7// Dependencies
8// ------------
9var istanbulReports = require('istanbul-reports')
10
11var customReporterMap = {}
12
13function register (reporter) {
14 var registeredType = reporter.TYPE
15 if (!registeredType) {
16 throw new Error('Registering a custom reporter requires a type!')
17 }
18
19 customReporterMap[registeredType] = reporter
20 return registeredType
21}
22
23function create (type, opts) {
24 var Reporter = customReporterMap[type]
25 if (Reporter) {
26 return new Reporter(opts)
27 }
28
29 // fallback to istanbul's report creator if reporter isn't found
30 return istanbulReports.create(type, opts)
31}
32
33function reset () {
34 customReporterMap = {}
35}
36
37module.exports = {
38 create: create,
39 register: register,
40 reset: reset
41}
Note: See TracBrowser for help on using the repository browser.