source: trip-planner-front/node_modules/istanbul-reports/lib/teamcity/index.js

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

initial commit

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[6a3a178]1/*
2 Copyright 2012-2015, Yahoo Inc.
3 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
4 */
5'use strict';
6const { ReportBase } = require('istanbul-lib-report');
7
8class TeamcityReport extends ReportBase {
9 constructor(opts) {
10 super();
11
12 opts = opts || {};
13 this.file = opts.file || null;
14 this.blockName = opts.blockName || 'Code Coverage Summary';
15 }
16
17 onStart(node, context) {
18 const metrics = node.getCoverageSummary();
19 const cw = context.writer.writeFile(this.file);
20
21 cw.println('');
22 cw.println("##teamcity[blockOpened name='" + this.blockName + "']");
23
24 //Statements Covered
25 cw.println(
26 lineForKey(metrics.statements.covered, 'CodeCoverageAbsBCovered')
27 );
28 cw.println(
29 lineForKey(metrics.statements.total, 'CodeCoverageAbsBTotal')
30 );
31
32 //Branches Covered
33 cw.println(
34 lineForKey(metrics.branches.covered, 'CodeCoverageAbsRCovered')
35 );
36 cw.println(lineForKey(metrics.branches.total, 'CodeCoverageAbsRTotal'));
37
38 //Functions Covered
39 cw.println(
40 lineForKey(metrics.functions.covered, 'CodeCoverageAbsMCovered')
41 );
42 cw.println(
43 lineForKey(metrics.functions.total, 'CodeCoverageAbsMTotal')
44 );
45
46 //Lines Covered
47 cw.println(
48 lineForKey(metrics.lines.covered, 'CodeCoverageAbsLCovered')
49 );
50 cw.println(lineForKey(metrics.lines.total, 'CodeCoverageAbsLTotal'));
51
52 cw.println("##teamcity[blockClosed name='" + this.blockName + "']");
53 cw.close();
54 }
55}
56
57function lineForKey(value, teamcityVar) {
58 return (
59 "##teamcity[buildStatisticValue key='" +
60 teamcityVar +
61 "' value='" +
62 value +
63 "']"
64 );
65}
66
67module.exports = TeamcityReport;
Note: See TracBrowser for help on using the repository browser.