Jest: Custom coverage format in json output

Created on 6 Dec 2016  路  7Comments  路  Source: facebook/jest

Do you want to request a feature or report a bug?
Feature / Question

What is the current behavior?
Not sure if this is the best place, but currently we can get the result programmatically via --json flag. The problem is when I try to integrate this to phabricator to collect code coverage, phabricator expects the coverage to have a specific format (for example NNNNNCCCNNNNNNNNCCCCCCNNNUUUNNNNN) as described here https://secure.phabricator.com/book/phabricator/article/arcanist_coverage/, but the json output cannot produce that out of the box. It outputs an object with statementMap, branchMap, etc inside the coverage property

Here's the current JSON output

{
  "testResults": [
    {
      "name": "/path/to/test/file",
      "coverage": {
        "/path/to/file/": {
          "path": "/path/to/file",
          "statementMap": {},
          "branchMap": {}
        }
      }
    }
  ]
}

What is the expected behavior?
Considering I heard FB also uses phabricator, do you think it's possible to support those custom format out of the box?

Here's the proposed JSON output

{
  "testResults": [
    {
      "name": "/path/to/test/file",
      "coverage": {
        "/path/to/file/": "NNCCCNNNNNNNNCCCCC"
      }
    }
  ]
}

Thanks :)

Most helpful comment

@kentaromiura is actually about to open source the code we use for coverage in phabricator at FB soon.

@ide who might care. This is super useful during code review.

All 7 comments

@kentaromiura is actually about to open source the code we use for coverage in phabricator at FB soon.

@ide who might care. This is super useful during code review.

Example:

screen shot 2016-12-06 at 8 32 55 pm

@cpojer good UI. Let鈥檚 change it by default. And move HTML page to coverage/ (right now it is on subdir) for better UX.

@ai this is not for the coverage html output. This is for phabricator integration: https://www.phacility.com/

@cpojer oops :(. Should I create issue with little HTML coverage tweaks? Or it is not so important?

the HTML coverage report is coming from istanbul, not from Jest: https://github.com/istanbuljs

We open sourced jest-phabricator-coverage with Jest 19. Feel free to use it as testResultsProcessor.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StephanBijzitter picture StephanBijzitter  路  3Comments

withinboredom picture withinboredom  路  3Comments

kentor picture kentor  路  3Comments

gustavjf picture gustavjf  路  3Comments

stephenlautier picture stephenlautier  路  3Comments