Skip to content

code coverage shows 0 when run from bazel test #1594

@gpradeepjain

Description

@gpradeepjain

I have set up NYC + mocha with Bazel. When I run the Bazel test, the mocha tests run fine, and I can see the results. My coverage report shows all the files in the src folder, but coverage is always 0.

load("@npm//:nyc/package_json.bzl", "bin")

def nyc_test(
    name,
    packagedir,
    tsconfig,
    deps = [],
    data = [],
    **kwargs):
    """Run NYC tests"""
    visibility = kwargs.pop("visibility", [])
    timeout = kwargs.pop("timeout", None)

    bin.nyc_test(
        name = name,
        args = [
            "--verbose",
            "--log-level",
            "debug",
            "--show-process-tree",
            "--exclude-node-modules",
            "false",
            "--all",
            "true",
            "--include",
            "src/**/*.js",
            "--include",
            "src/**/*.ts",
            "--check-coverage",
            "true",
            "--reporter",
            "lcov",
            "--reporter",
            "text-summary",
            "../../node_modules/mocha/bin/mocha.js",
             "%s/**/*.js" % packagedir
            ],
        chdir = native.package_name(),
        data = data + deps + [
            tsconfig,
            "//:tsconfig",
            "//:node_modules",
        ],
        visibility = visibility,
        **kwargs,
    )

=============================== Coverage summary ===============================
Statements : 0% ( 0/735 )
Branches : 0% ( 0/145 )
Functions : 0% ( 0/108 )
Lines : 0% ( 0/709 )

---------------------------------------|---------|----------|---------|---------|-------------------

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 0 0 0 0
src 0 0 0 0
ab.ts 0 0 0 0 6-79
cd.ts 0 100 100 0 5-12

Does NYC work with bazel ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions