Skip to content

Commit

Permalink
Updated the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Jan 22, 2017
1 parent 871bb09 commit fd2f3f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog
This file contains highlights of what changes on each version of the [LCOV Reports for JS](https://github.com/cedx/lcov.js) library.

## Version 0.2.0
- Breaking change: changed the signature of most constructors.
- Empty test names are not included in the report output.
- Updated the package dependencies.

## Version 0.1.0
- Initial release.
43 changes: 12 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,52 +72,33 @@ The `Report.toJSON()` instance method will return a map like this:

### Format coverage data to the [LCOV](http://ltp.sourceforge.net/coverage/lcov.php) format
Each provided class has a dedicated `toString()` instance method returning the corresponding data formatted as LCOV string.
All you have to do is to create the adequate structure using these different classes, and to export the final result using the `Report.toString()` method:
All you have to do is to create the adequate structure using these different classes, and to export the final result:

```javascript
const {FunctionCoverage, LineCoverage, LineData, Record, Report} = require('@cedx/lcov');

let lineData = new LineData({
checksum: 'PF4Rz2r7RTliO9u6bZ7h6g',
executionCount: 2,
lineNumber: 6
});

let lineCoverage = new LineCoverage({
data: [lineData, ...],
found: 4,
hit: 4
});

let record = new Record({
functions: new FunctionCoverage({data: [...], found: 1, hit: 1}),
lines: lineCoverage,
sourceFile: '/home/cedx/lcov.js/fixture.js'
});

let report = new Report({
records: [record],
testName: 'Example'
});
let record = new Record('/home/cedx/lcov.js/fixture.js');
record.functions = new FunctionCoverage(1, 1);
record.lines = new LineCoverage(2, 2, [
new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'),
new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w')
]);

let report = new Report('Example', [record]);
console.log(report.toString());
```

It will return a LCOV report formatted like this:
The `Report.toString()` method will return a LCOV report formatted like this:

```
TN:Example
SF:/home/cedx/lcov.js/fixture.js
FN:4,main
FNDA:2,main
SF:/home/cedx/lcov.dart/fixture.js
FNF:1
FNH:1
DA:6,2,PF4Rz2r7RTliO9u6bZ7h6g
DA:7,2,yGMB6FhEEAd8OyASe3Ni1w
DA:8,2,8F2cpOfOtP7xrzoeUaNfTg
DA:9,2,y7GE3Y4FyXCeXcrtqgSVzw
LF:4
LH:4
LF:2
LH:2
end_of_record
```

Expand Down

0 comments on commit fd2f3f0

Please sign in to comment.