privatenumber / tsx

⚡️ TypeScript Execute | The easiest way to run TypeScript in Node.js
https://tsx.is
MIT License
8.61k stars 132 forks source link

c8 incorrectly reports 100% coverage when using tsx #558

Closed nwalters512 closed 1 month ago

nwalters512 commented 1 month ago

Acknowledgements

Minimal reproduction URL

https://github.com/nwalters512/tsx-c8-coverage-repro

Problem & expected behavior (under 200 words)

I would expect c8's coverage reports to show something less than 100%, given that my "tests" in src/index.test.ts don't execute the subtract function from index.ts. However, they still report 100% coverage, and don't capture the fact that the code has multiple lines (this is the coverage shown by coverage/index.ts.html after running npm test in the reproduction):

Screenshot 2024-05-16 at 14 43 09

I acknowledge that this issue is very similar to https://github.com/privatenumber/tsx/issues/433. However, it still reproduces on the latest version of tsx, so I felt it best to open a new issue. I based my reproduction on the one from that issue, but stripped it down to be as minimal as possible.

This is reproducible on Node 18, Node 20, and Node 22 (I tried all via nvm use ...).

Bugs are expected to be fixed by those affected by it

Compensating engineering work financially will speed up resolution

nwalters512 commented 1 month ago

I might have opened this prematurely, sorry! I saw https://github.com/pvtnbr/tsx/pull/16 in the development repo, and the bot comment said it was available in 4.9.4-rc.1, so I assumed that the latest version (4.10.3) would contain those changes since it was after 4.9.4-rc.1. However, looking at the relevant line on master, it seems like this changes haven't made it back to this repo yet:

https://github.com/privatenumber/tsx/blob/05c382f4b6f17310fbcc09b2580dc262a8a652ca/src/utils/transform/get-esbuild-options.ts#L24

@privatenumber let me know if I just have to wait for this change to trickle down into an official build!

privatenumber commented 1 month ago

Just released it for ya in https://github.com/privatenumber/tsx/releases/tag/v4.10.4

I appreciate the sponsorship! Thanks @nwalters512