Skip to content

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

Description

@muturgan

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

Activity

  1. avivkeller commented on Jul 4, 2024

    @avivkeller
    Member

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

  2. added
    test_runnerIssues and PRs related to the test runner subsystem.
    on Jul 4, 2024
  3. muturgan commented on Jul 4, 2024

    @muturgan
    Author

    RedYetiDev

    I will try

  4. cjihrig commented on Jul 4, 2024

    @cjihrig
    Contributor

    Are you enabling source maps?

  5. muturgan commented on Jul 4, 2024

    @muturgan
    Author

    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')

  6. cjihrig commented on Jul 4, 2024

    @cjihrig
    Contributor

    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?

  7. muturgan commented on Jul 5, 2024

    @muturgan
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions