chutzpah

Code coverage when using Html test file


I want to generate Jacoco report for code coverage so I can included in my TFS build as described here https://www.linkedin.com/pulse/enabling-javascripttypescript-code-coverage-brett-jacobson?trk=portfolio_article-card_title.

For that, I used almost the same chutzpah.json file:

{
    "Compile": {
        "Mode": "External",
        "Extensions": [ ".ts" ],
        "ExtensionsWithNoOutput": [ ".d.ts" ]
    },
    "CodeCoverageExecutionMode": "Always",
    "EnableCodeCoverage": "True",
    "CodeCoverageExcludes": [
        "node_modules/*"
    ],
    "TestFileTimeout": 5000,
    "Tests": [
        {
            "Path": "test\\unittests\\index.html"
        }
    ],
    "Transforms": [
        {
            "Name": "jacoco",
            "Path": "..\\TestResults\\ChutzpahJacoco.xml"
        },
        {
            "Name": "lcov",
            "Path": "..\\TestResults\\ChutzpahJS.lcov"
        },
        {
            "Name": "coveragehtml",
            "Path": "..\\TestResults\\ChutzpahJS.html"
        }
    ]
}

Inside my index.html file, I have all my unit tests. Giving this config, if I run

chutzpah.console.exe chutzpah.json

command, I get the result of all total and failed tests. But the 3 transforms reports are not generated.

However, if I change Tests settings to use Includes": [ "*Tests.ts" ] instead of a path to HTML file and add references, I will get reports generated.

Is this a limitation with Html test file or am I doing something wrong?


Solution

  • Chutzpah will not do code coverage for you if you are using HTML file. It only supports it if you let Chutzpah generate the HTML for you.