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

Jest coverage with @swc/jest reports imports (and other differences) #9501

Open
SimonMueller opened this issue Aug 26, 2024 · 2 comments
Open
Assignees
Labels
Milestone

Comments

@SimonMueller
Copy link

SimonMueller commented Aug 26, 2024

Describe the bug

After switching from babel-jest to @swc/jest as jest transformer and after running the coverage again i saw some really different and higher numbers of coverage with @swc/jest.

I investigated for a bit and found the main cause to be that the module imports are reported as relevant and therefore covered lines aswell. This changes the coverage percentage of a bigger project drastically as shown in the reproduction linked.

Is this behaviour intended or did i miss something in the configs?

Thx in advance.

Input code

See reproduction repo.

Config

See reproduction repo.

Playground link (or link to the minimal reproduction)

https://github.com/SimonMueller/swc-jest-coverage-repro

SWC Info output

Operating System:
    Platform: linux
    Arch: x64
    Machine Type: x86_64
    Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
    CPU: (16 cores)
        Models: Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz

Binaries:
    Node: 20.11.0
    npm: 10.2.4
    Yarn: 1.22.15
    pnpm: N/A

Relevant Packages:
    @swc/core: 1.7.18
    @swc/helpers: N/A
    @swc/types: 0.1.12
    typescript: 5.1.6

SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

Same coverage report as with "babel-jest" transformer.

Actual behavior

Imports are reported as relevant lines and coverage report has other differences too which results in a much higher coverage than with "babel-jest".

Version

1.7.18

Additional context

No response

@kdy1 kdy1 added this to the Planned milestone Aug 26, 2024
@kdy1 kdy1 self-assigned this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants
@SimonMueller @kdy1 and others