-
-
Notifications
You must be signed in to change notification settings - Fork 230
/
index.js
57 lines (53 loc) · 1.74 KB
/
index.js
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
'use strict';
/* globals describe, it, beforeEach, before, after */
const fs = require('fs');
const path = require('path');
const isWindows = require('is-windows');
const FileWriter = require('istanbul-lib-report/lib/file-writer');
const istanbulLibReport = require('istanbul-lib-report');
const istanbulLibCoverage = require('istanbul-lib-coverage');
const CoberturaReport = require('../../lib/cobertura/index');
require('chai').should();
describe('CoberturaReport', () => {
before(() => {
FileWriter.startCapture();
});
after(() => {
FileWriter.stopCapture();
});
beforeEach(() => {
FileWriter.resetOutput();
});
function createTest(file) {
const fixture = require(path.resolve(
__dirname,
'../fixtures/specs/' + file
));
it(fixture.title, function() {
if (isWindows()) {
// appveyor does not render console color.
return this.skip();
}
const context = istanbulLibReport.createContext({
dir: './',
coverageMap: istanbulLibCoverage.createCoverageMap(fixture.map)
});
const tree = context.getTree('pkg');
const report = new CoberturaReport({
file: '-',
timestamp: '123456789',
...fixture.opts
});
tree.visit(report, context);
const output = FileWriter.getOutput();
output.should.equal(fixture.coberturaCoverageData);
});
}
fs.readdirSync(path.resolve(__dirname, '../fixtures/specs')).forEach(
file => {
if (file.indexOf('.json') !== -1) {
createTest(file);
}
}
);
});