Jest_test rule bazel coverage report returning empty data
pmdawood opened this issue Β· comments
π bug report
Affected Rule
jest_test
Is this a regression?
no
Description
we have running our jest based unit test case using jest_test rule.the target is running fine.but the coverage data coming as empty.
we are using "bazel coverage --combined_report=lcov :test". i have tried the test target under rules_nodejs/example/jest/ts/test.
while running this target initially i have got "ERROR: c8 npm package is required for bazel coverage" this error. its complaining c8 was not there.Then i have added c8 node module.now i have got the below messages
INFO: LCOV coverage report is located at /home/xxxx/.cache/bazel/_bazel_xxx/0b882d570d6913661009bd34305d0f0c/execroot/examples_jest/bazel-out/_coverage/_coverage_report.dat
and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: From Coverage report generation:
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file bazel-out/k8-fastbuild/testlogs/ts/test/test/coverage.dat
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Please let me know, what could be the problem.any workaround to move ahead for bazel coverage.
π¬ Minimal Reproduction
- Go to rules_nodejs/example/jest/ts/test - package.json missing c8 npm, add "c8" npm and generate yarn.lock file.
- Then run bazel coverage --combined_report=lcov :test. Test will run successfully and coverage.dat generated under bazel_out but the data is empty.
π₯ Exception or Error
INFO: From Coverage report generation:
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file bazel-out/k8-fastbuild/testlogs/ts/test/test/coverage.dat
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Sep 29, 2022 2:21:46 AM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
π Your Environment
Operating System:
Linux - ubuntu
Output of bazel version
:
bazel 5.3.1
Rules_nodejs version:
(Please check that you have matching versions between WORKSPACE file and @bazel/*
npm packages.)
rules_nodejs-5.5.0
Anything else relevant?
I have the same issue;
Even setting doesn't work:
coverageProvider: 'v8',
the problem here is that examples/jest:test
does not provide any target that exports coverage_common.instrumented_files_info
therefore bazel decides that there are no targets/files to instrument.
if we change
rules_nodejs/internal/node/node.bzl
Line 388 in a81a4ab
source_attributes
instead of dependency_attributes
then the jest example will work but that's not the ideal solution to this problem.This should all work better with https://github.com/aspect-build/rules_jest which is built on top of https://github.com/aspect-build/rules_js if you are not tied to rules_nodejs
@gregmagolan but what's the solve for folks who haven't migrated yet :)?
@Aghassi I guess you can just patch in the suggestion above #3564 (comment) so that data
is a source_attribute.
This issue has been automatically marked as stale because it has not had any activity for 6 months. It will be closed if no further activity occurs in 30 days. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!
This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"