File: coverage.json.md

package info (click to toggle)
node-istanbul 0.4.5%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,264 kB
  • sloc: sh: 22; makefile: 10; xml: 1
file content (43 lines) | stat: -rw-r--r-- 3,027 bytes parent folder | download | duplicates (6)
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
# Format of coverage.json

`coverage.json` contains a report object, which is a hash where keys are file names (absolute
paths), and values are coverage data for that file (the result of
`json.stringify(collector.fileCoverageFor(filename))`)  Each entry consists of:

* `path` - The path to the file.  This is an absolute path, and should be the same as the
  key in the report object.
* `s` - Hash of statement counts, where keys as statement IDs.
* `b` - Hash of branch counts, where keys are branch IDs and values are arrays of counts.
  For an if statement, the value would have two counts; one for the if, and one for the
  else.  Switch statements would have an array of values for each case.
* `f` - Hash of function counts, where keys are function IDs.
* `fnMap` - Hash of functions where keys are function IDs, and values are `{name, line, loc, skip}`,
  where `name` is the name of the function, `line` is the line the function is declared on,
  and `loc` is the `Location` of the function declaration (just the declaration, not the entire
  function body - see 'Location Objects' below.)  If `skip` is present and true, then this
  indicates that this function was ignored by a `### instabul ignore ... ###` pragma.  Note that
  if a function is not ignored the `skip` field will be missing entirely.
* `statementMap` - Hash where keys are statement IDs, and values are `Location` objects for each
  statement.  The `Location` for a function definition is really an assignment, and should
  include the entire function.  In addition to the normal location object fields, a
  `statementMap` entry can also have an optional `skip` field.
* `branchMap` - Hash where keys are branch IDs, and values are `{line, type, locations}` objects.
  `line` is the line the branch starts on.  `type` is the type of the branch (e.g. "if", "switch").
  `locations` is an array of `Location` objects, one for each possible outcome of the branch.
  Note for an `if` statement where there is no `else` clause, there will still be two `locations`
  generated.  Istanbul does *not* generate coverage for the `default` case of a switch statement
  if `default` is not explicitly present in the source code.
* `l` - Hash of line counts, where keys are the line number.

  `locations` for an if statement are always 0-length and located at the start of the `if` (even
  the location for the "else").  For a `switch` statement, `locations` start at the start of the
  `case` statement and go to the end of the line before the next case statement (note Istanbul
  does nothing clever here if a `case` is missing a `break`.)  Each location in `locations` can
  also optionally have a `skip: true` field to indicate that this branch was ignored.

IDs used in the fnMap, statementMap, and branchMap are sequential integers, starting at 1.

## Location Objects

Location objects are a `{start: {line, column}, end: {line, column}}` object that describes
the start and end of a piece of code.  Note that `line` is 1-based, but `column` is 0-based.