Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test_runner: --experimental-test-coverage detects uncovered lines incorrectly. #53719

Closed
muturgan opened this issue Jul 4, 2024 · 6 comments
Closed
Labels
test_runner Issues and PRs related to the test runner subsystem.

Comments

@muturgan
Copy link

muturgan commented Jul 4, 2024

Version

20.15.0

Platform

Darwin macbook-WQW3312KW0 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64

Subsystem

No response

What steps will reproduce the bug?

  1. git clone git@github.com:muturgan/fastest-express-validator.git
  2. cd fastest-express-validator && npm ci && npm run build
  3. npm run test_coverage
  4. look at the uncovered lines colunm of a dist/index.cjs file

How often does it reproduce? Is there a required condition?

It reproduces every time. No special conditions are needed.

What is the expected behavior? Why is that the expected behavior?

Report of a dist/index.cjs file is NOT contains 53-55 uncovered lines (which corresponds to a defaultRequestValidatorHandler success branch). Because of I have a correct user request test case which not produces a validation error.

What do you see instead?

The coverage report of a dist/index.cjs file mark 53-55 lines as uncovered.

Additional information

No response

@RedYetiDev
Copy link
Member

Thanks for the report! Could you provide a minimally reproducible example? One without any external dependencies / repos?

@RedYetiDev RedYetiDev added the test_runner Issues and PRs related to the test runner subsystem. label Jul 4, 2024
@muturgan
Copy link
Author

muturgan commented Jul 4, 2024

RedYetiDev

I will try

@cjihrig
Copy link
Contributor

cjihrig commented Jul 4, 2024

Are you enabling source maps?

@muturgan
Copy link
Author

muturgan commented Jul 4, 2024

Are you enabling source maps?

No, but how it should affects a test coverage? Tests running on already compiled and not minified code.

But affects in fact. I have tried to enable sourceMap in a tsconfig. In this case tests were passed successfully but coverage calculation failed with a message: Warning: Could not report code coverage. TypeError: Cannot read properties of undefined (reading 'line')

@cjihrig
Copy link
Contributor

cjihrig commented Jul 4, 2024

Hm, I tried running the tests and added some print statements. The if (Object.keys(errors).length === 0) statement in question was never entered for me. Maybe I'm doing something wrong?

@muturgan
Copy link
Author

muturgan commented Jul 5, 2024

Hm, I tried running the tests and added some print statements. The if (Object.keys(errors).length === 0) statement in question was never entered for me. Maybe I'm doing something wrong?

I read the tests very carefully. Yeah, it turns out that this check looks appropriate in the context of a single function. But from the outside this function is called in such a way that this condition will never be fulfilled. A kind of overkill. I apologize for the time spent. It seems that everything fine with the coverage calculation.

@muturgan muturgan closed this as completed Jul 5, 2024
@RedYetiDev RedYetiDev reopened this Jul 5, 2024
@RedYetiDev RedYetiDev closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test_runner Issues and PRs related to the test runner subsystem.
3 participants